iOS UI-手势(Gesture)
#import "ViewController.h" @interface ViewController ()<UIActionSheetDelegate>
@property (strong, nonatomic) UITextField *me_textfield; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor lightGrayColor]];
/*
手势分类:
滑动手势、点击手势、双击手势、长按手势等7种
*/ // self.me_textfield = [[UITextField alloc] initWithFrame:CGRectMake(0, 100, 375, 100)];
// self.me_textfield.placeholder = @"请输入";
// self.me_textfield.borderStyle = UITextBorderStyleRoundedRect;
// //self.me_textfield.center =self.view.center;
// [self.view addSubview:self.me_textfield]; //创建点击手势
UITapGestureRecognizer *click = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToDoSomething)];
[self.view addGestureRecognizer:click]; //创建长按手势
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressToDoSomething)];
longPress.minimumPressDuration = 2.0;
[self.view addGestureRecognizer:longPress]; //创建捏合手势
UIPinchGestureRecognizer *pich = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pichToDoSomething)];
[self.view addGestureRecognizer:pich]; //创建旋转手势
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationToDoSomething)];
[self.view addGestureRecognizer:rotation]; //创建轻扫手势
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToDoSomething)];
[self.view addGestureRecognizer:swipe]; //创建拖动手势
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panToDoSomething)];
[self.view addGestureRecognizer:pan]; //创建屏幕边缘拖动手势
UIScreenEdgePanGestureRecognizer *screenEdgePan =[[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenEdgePanToDoSomething)];
[self.view addGestureRecognizer:screenEdgePan];
}
#pragma mark - 屏幕边缘拖动手势关联方法
- (void)screenEdgePanToDoSomething
{
NSLog(@"屏幕边缘拖动");
}
#pragma mark - 拖动手势关联方法
- (void)panToDoSomething
{
NSLog(@"拖动");
}
#pragma mark - 轻扫手势关联方法
- (void)swipeToDoSomething
{
NSLog(@"轻扫");
}
#pragma mark - 旋转手势关联方法
- (void)rotationToDoSomething
{
NSLog(@"旋转");
}
#pragma mark - 捏合手势关联方法
- (void)pichToDoSomething
{
NSLog(@"捏合");
}
#pragma mark - 长按手势关联方法
- (void)longPressToDoSomething
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"关机" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
[alert show];
}
#pragma mark - 点击手势关联方法
- (void)clickToDoSomething
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"你点我试试" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
[alert show]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
iOS UI-手势(Gesture)的更多相关文章
- 点击事件touches与ios的手势UIGestureRecognizer
.h文件 @property (weak,nonatomic) IBOutlet UILabel *messageLabel;@property (weak,nonatomic) IBOutlet U ...
- IOS UI 第八篇:基本UI
实现图片的滚动,并且自动停止在每张图片上 - (void)viewDidLoad{ [super viewDidLoad]; UIScrollView *scrollView = [[U ...
- android学习笔记52——手势Gesture,增加手势、识别手势
手势Gesture,增加手势 android除了提供了手势检测之外,还允许应用程序把用户手势(多个持续的触摸事件在屏幕上形成特定的形状)添加到指定文件中,以备以后使用 如果程序需要,当用户下次再次画出 ...
- android学习笔记51——SQLite 手势Gesture
手势Gesture 所谓手势,是指用户手指或触摸笔在触摸屏幕上的连续触碰行为. Androi对两种手势行为都提供了支持: 1.对于第一种手势而言,android提供了手势检测,并为手势检测提供了相应的 ...
- [IOS]IOS UI指南
[IOS]IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻 ...
- [BS-25] IOS中手势UIGestureRecognizer概述
IOS中手势UIGestureRecognizer概述 一.概述 iPhone中处理触摸屏的操作,在3.2之前是主要使用的是由UIResponder而来的如下4种方式: - (void)touches ...
- IOS各种手势操作实例
先看下效果 手势相关的介绍 IOS中手势操作一般是 UIGestureRecognizer 类的几个手势子类去实现,一般我们用到的手势就这么5种: 1.点击 UITapGestureRecogniz ...
- 国外IOS UI指南
国外IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻译) ...
- iOS UI的几种模式
iOS UI的几种模式: 1.平凡模式(原生控件组合): 2.新闻模式: 3.播放器模式: 4.微博模式:
- IOS中手势UIGestureRecognizer
通常在对视图进行缩放移动等操作的时候我们可以用UIScrollView,因为它里边自带了这些功能,我们要做的就是告诉UIScrollView的几个相关参数就可以了 但是没有实现旋转的手势即UIRota ...
随机推荐
- P4391 [BOI2009]Radio Transmission 无线传输
P4391 [BOI2009]Radio Transmission 无线传输 kmp 题目让我们求一个串的最小循环子串 我们回想一下kmp中的失配函数 用 f 数组保存当前字符匹配失败后,需要跳到的前 ...
- 写给java程序员的c++与java实现的一些重要细微差别-附完整版pdf学习手册
0.其实常规的逻辑判断结构.工具类.文件读写.控制台读写这些的关系都不大,熟悉之后,这些都是灵活运用的问题. 学习c/c++需要预先知道的一个前提就是,虽然有ANSI C标准,但是每个c/c++编译器 ...
- 20145327 《网络对抗》逆向及BOF基础实践
20145327 <网络对抗>逆向及BOF基础实践 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任 ...
- MFC使用MsComm做串口通信
一.注册MSCOMM 1.下载控件MSCOMM32.OCX(32位),mswnisck.ocx(64位) 2.把这个ocx文件放在c盘WIndows的system32里,打开cmd执行:regsvr3 ...
- Git 基础 —— 常见使用场景
Git 基础学习系列 Git 基础 -- 安装 配置 别名 对象 Git 基础 -- 常用命令 Git 基础 -- 常见使用场景 Git基础 -- Github 的使用 突然插入 Bugifx 工作, ...
- 动态规划模板1|LIS最长上升子序列
LIS最长上升子序列 dp[i]保存的是当前到下标为止的最长上升子序列的长度. 模板代码: int dp[MAX_N], a[MAX_N], n; int ans = 0; // 保存最大值 for ...
- yarn虚拟cpu和虚拟内存
虚拟cpu 虚拟的cpu代码并发数,如果一个container拥有2个vcpu,那么该container就可以真正的在同一时间运行两个线程,而不是靠切时间片而达到的逻辑并发.所以一般虚拟的cpu需要和 ...
- python 获取当前时间戳
#!/usr/bin/python # -*- coding: UTF- -*- import time; # 引入time模块 ticks = time.time() print("当前时 ...
- Qt_QString.indesOf和mid测试
1.indexOf #define GID_PREFIX "dr_" QString str = "dr__awedr4"; int iIdx = str.in ...
- 很火的Java题——判断一个整数是否是奇数
完成以下代码,判断一个整数是否是奇数: public boolean isOdd(int i) 看过<编程珠玑>的人都知道这道题的答案和其中极为简单的道理. 最普遍的风格,如下: 这个函数 ...