ios 中手势用法
pan拖动手势
- (void)viewDidLoad
{
[super viewDidLoad];
[self Pan];
// Do any additional setup after loading the view, typically from a nib.
} #pragma mark -拖动手势Pan
-(void)Pan{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
[view release]; UIPanGestureRecognizer *pin=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pin:)];
[view addGestureRecognizer:pin];
[pin release];
} -(void)pin:(UIPanGestureRecognizer*)pin{
//得到pin移动的位置,向左拖动是左拖动x为负数,向上拖动y为负数,向下拖动y为整数,向右边拖动为x为整数
CGPoint point= [pin translationInView:self.view];
NSLog(@"%@",NSStringFromCGPoint(point));
//手势结束的状态
if(pin.state==UIGestureRecognizerStateEnded){
NSLog(@"手指已离开屏幕,手势结束");
} //注意一定要加下面一句 ,清除手势为原来坐标
[pin setTranslation:CGPointZero inView:self.view]; }
缩放手势
- (void)viewDidLoad
{
[super viewDidLoad];
[self Princh];
// Do any additional setup after loading the view, typically from a nib.
} #pragma mark -Princh
-(void)Princh{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
UIPinchGestureRecognizer *pinch=[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[view addGestureRecognizer:pinch];
[pinch release]; [view release]; } -(void)pinch:(UIPinchGestureRecognizer *)pin{ //主要属性
CGFloat scale= pin.scale;
pin.view.transform=CGAffineTransformScale(pin.view.transform, pin.scale, pin.scale);
if(pin.state==UIGestureRecognizerStateEnded){ }
scale=; }
缩放
[self Rotaion];
// Do any additional setup after loading the view, typically from a nib.
} #pragma mark -Princh
-(void)Rotaion{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
UIRotationGestureRecognizer *rotation=[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rote:)];
[view addGestureRecognizer:rotation]; [view release]; } -(void)rote:(UIRotationGestureRecognizer *)rotation{
CGFloat rt=rotation.rotation;
rotation.view.transform=CGAffineTransformRotate(rotation.view.transform, rt);
if(rotation.state==UIGestureRecognizerStateEnded){ }
rt=;
}
Tap手势
-(void)Rotaion{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[view addGestureRecognizer:tap];
[tap release];
}
-(void)tap:(UITapGestureRecognizer *)tap{
tap.view.backgroundColor=[UIColor yellowColor];
}
原文地址:http://blog.csdn.net/totogo2010/article/details/8615940
ios 中手势用法的更多相关文章
- [BS-25] IOS中手势UIGestureRecognizer概述
IOS中手势UIGestureRecognizer概述 一.概述 iPhone中处理触摸屏的操作,在3.2之前是主要使用的是由UIResponder而来的如下4种方式: - (void)touches ...
- IOS中手势UIGestureRecognizer
通常在对视图进行缩放移动等操作的时候我们可以用UIScrollView,因为它里边自带了这些功能,我们要做的就是告诉UIScrollView的几个相关参数就可以了 但是没有实现旋转的手势即UIRota ...
- ios 中pickerView用法之国旗选择
QRViewController控制器 // // QRViewController.m // #import "QRViewController.h" #import " ...
- ios中MKHorizMenu用法
下载地址 https://github.com/MugunthKumar/MKHorizMenuDemo直接 加入MKHorizMenu目录即可 下载包地址 http://pan.baidu.com/ ...
- IOS各种手势操作实例
先看下效果 手势相关的介绍 IOS中手势操作一般是 UIGestureRecognizer 类的几个手势子类去实现,一般我们用到的手势就这么5种: 1.点击 UITapGestureRecogniz ...
- iOS中的触摸事件和手势处理
iOS中的事件可以分为三大类: 1> 触摸事件 2> 加速计事件 3> 远程控制事件 响应者对象 在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并 ...
- iOS中block的用法 以及和函数用法的区别
ios中block的用法和函数的用法大致相同 但是block的用法的灵活性更高: 不带参数的block: void ^(MyBlock)() = ^{}; 调用的时候 MyBlock(); 带参数的 ...
- 【IOS】ios中NSUserDefault与android中的SharedPreference用法简单对比
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3405308.html 有Android开发经验的朋友对Shar ...
- 说说iOS中的手势及触摸
一.响应链 在IOS开发中会遇到各种操作事件,通过程序可以对这些事件做出响应. 首先,当发生事件响应时,必须知道由谁来响应事件.在IOS中,由响应者链来对事件进行响应,所有事件响应的类都是UIResp ...
随机推荐
- 面试题-Redis、MongoDB、Memcached[转]
https://blog.csdn.net/gangsijay888/article/details/81213811 一.缓存 搞懂缓存那些事:https://blog.csdn.net/a7248 ...
- css控制input标签
逛到发现这个 个人感觉非常赞 下面是CSS样式 Js代码 input { border:1px solid #B3D6EF; background: ...
- 谁为你的app捡肥皂
2048奇迹,是大多数个人开发者的梦寐以求的期望.而做出flappy bird这样跨时代的游戏,则能够让我们赚的盆满钵满.那么我们怎么样使我们app与众不同,脱颖而出了. 我们这些凡夫俗子程序员们,对 ...
- InvalidateRect,invalidate,updatewindow(转)
InvalidateRect(HWND) 使窗口无效 产生消息WM_PAINT; ValidateRect(HWND)使窗口有效 清除消息队列中的WM_PAINT消息 在编程的时候经常把UpdateD ...
- Kendall's tau-b(肯德尔)等级相关系数
Kendall's tau-b(肯德尔)等级相关系数:用于反映分类变量相关性的指标,适用于两个分类变量均为有序分类的情况.对相关的有序变量进行非参数相关检验:取值范围在-1-1之间,此检验适合于正方形 ...
- Mysql 创建表时错误:Tablespace for table `tablexx` exists. Please DISCARD the tablespace before IMPORT.
在本地的一个数据库创建表时意外的出现了以下错误,说是表已经存在了 但通过desc 查看表信息时又说表不存在 在本地系统搜索表名却发现一个.ibd文件[InnoDB File] 在删除了该.ibd文件文 ...
- Linux中盘符的两种挂载方法
相信接触过Linux系统的人对于mount命令都不陌生,今天是农历2017年的最后一个工作日,趁着时光还在,就说一下两种不同的挂载方法吧. 课前小知识: 命令格式:mount [-t vfstype] ...
- [Spring boot] Autowired by name, by @Primary or by @Qualifier
In the example we have currently: @Component public class BinarySearchImpl { @Autowired private Sort ...
- 在SpringTest中将Mockito的mock对象通过spring注入使用
转载:https://blog.csdn.net/m0_38043362/article/details/80111957 1. 原理介绍 通过BeanFactoryPostProcessor向Bea ...
- GitHub没有实时通知怎么办?当然是自己上手写一个啊!
相信各位程序员对github已经不陌生了.不知道各位有没有注意到GitHub没有推送通知这个功能.当有人在我的存储库中创建了一个提取请求/问题时,我可以收到电子邮件通知,但当有人stars/forks ...