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 中手势用法的更多相关文章

  1. [BS-25] IOS中手势UIGestureRecognizer概述

    IOS中手势UIGestureRecognizer概述 一.概述 iPhone中处理触摸屏的操作,在3.2之前是主要使用的是由UIResponder而来的如下4种方式: - (void)touches ...

  2. IOS中手势UIGestureRecognizer

    通常在对视图进行缩放移动等操作的时候我们可以用UIScrollView,因为它里边自带了这些功能,我们要做的就是告诉UIScrollView的几个相关参数就可以了 但是没有实现旋转的手势即UIRota ...

  3. ios 中pickerView用法之国旗选择

    QRViewController控制器 // // QRViewController.m // #import "QRViewController.h" #import " ...

  4. ios中MKHorizMenu用法

    下载地址 https://github.com/MugunthKumar/MKHorizMenuDemo直接 加入MKHorizMenu目录即可 下载包地址 http://pan.baidu.com/ ...

  5. IOS各种手势操作实例

    先看下效果 手势相关的介绍 IOS中手势操作一般是 UIGestureRecognizer 类的几个手势子类去实现,一般我们用到的手势就这么5种: 1.点击  UITapGestureRecogniz ...

  6. iOS中的触摸事件和手势处理

    iOS中的事件可以分为三大类: 1> 触摸事件 2> 加速计事件 3> 远程控制事件 响应者对象 在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并 ...

  7. iOS中block的用法 以及和函数用法的区别

    ios中block的用法和函数的用法大致相同 但是block的用法的灵活性更高: 不带参数的block: void ^(MyBlock)() = ^{}; 调用的时候  MyBlock(); 带参数的 ...

  8. 【IOS】ios中NSUserDefault与android中的SharedPreference用法简单对比

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3405308.html 有Android开发经验的朋友对Shar ...

  9. 说说iOS中的手势及触摸

    一.响应链 在IOS开发中会遇到各种操作事件,通过程序可以对这些事件做出响应. 首先,当发生事件响应时,必须知道由谁来响应事件.在IOS中,由响应者链来对事件进行响应,所有事件响应的类都是UIResp ...

随机推荐

  1. Spring Boot集成JasperReports生成PDF文档

    由于工作需要,要实现后端根据模板动态填充数据生成PDF文档,通过技术选型,使用Ireport5.6来设计模板,结合JasperReports5.6工具库来调用渲染生成PDF文档.本人文采欠缺,写作能力 ...

  2. multiMap遍历方法

    /* multimap中的三种遍历方法 multimap中如果没有查找到相应元素,则返回的迭代器是依据该元素的排列顺序该键应该插入的位置 如果找不到,则方法一和方法二返回的两个迭代器应该相等 */ # ...

  3. 【API规范】OpenAPI规范

    OpenAPI规范 openAPI 3.0_百度搜索 OpenAPI Specification 2.0 - CSDN博客 APP相关_API 列表_OpenAPI 2.0_开发指南_移动推送-阿里云 ...

  4. 在浏览器中直接调用webservice的正确写法

    此文章针对webwork+spring+hibernate的工程,对于其他框架应该一样适用,首先在wsdd文件中找到所需webservice的名称,例如以下写法: <service name=& ...

  5. LDR 和MOV 指令区别

    ARM是RISC结构,数据从内存到CPU之间的移动只能通过L/S指令来完成,也就是ldr/str指令.比如想把数据从内存中某处读取到寄存器中,只能使用ldr比如:ldr r0, 0x12345678就 ...

  6. wget获取整站

    wget -m -e robots=off https://www.baidu.com -m是克隆整个网站,-e robots=off是让wget忽视robots.txt 如果网站有中文路径,最好用以 ...

  7. mysql中ibdata1过大的问题

    ibdata1文件是什么? 答: ibdata1是一个用来构建innodb系统表空间的文件,这个文件包含了innodb表的元数据.撤销记录.修改buffer和双写buffer.如果file-per-t ...

  8. Discuz常见小问题-如何人为地添加用户并分配小组

    进入后台,在用户-添加用户中可以人为添加用户并分配权限

  9. Ubuntu IntelliJ IDEA 注冊碼與Gradle相關

    一.Ubuntu IntelliJ IDEA 注冊碼 在线免费生成IntelliJ IDEA 15.0(16.+)注册码 注冊參考:https://www.iteblog.com/idea/ 依次选择 ...

  10. 使用Spring框架入门三:基于XML配置的AOP的使用

    一.引入Jar包 <!--测试1使用--> <dependency> <groupId>org.springframework</groupId> &l ...