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. Cesium学习笔记(七):Demo学习(自由控制飞行的飞机)[转]

    https://blog.csdn.net/umgsoil/article/details/74923013# 这是官方的教程Demo,名字叫Use HeadingPitchRoll,顾名思义,就是教 ...

  2. vNetwork Standard Switch(vSS)和vNetwork Distributed Switch(vDS)的区别

    vSS: vSwitches are configured on each ESXi/ESX host. vDS: The configuration of vDS is centralized to ...

  3. SQL 连接操作 及 查询分析

  4. ASP入门(十九)- SELECT 语句

    SELECT 语法 Access 中 SELECT 完整语法如下: SELECT [predicate] { * | table.* | [table.]field1 [AS alias1] [, [ ...

  5. ImportError DLL load failed: %1 不是有效的 Win32 应用程序

    操作系统:win7 64位,安装mysqldb 后提示:ImportError DLL load failed: %1 不是有效的 Win32 应用程序,是由于安装的32位的 MySQL-Python ...

  6. 阿里云centos 6安装iRedmail过程

    全新系统 yum update cd /root wget http://www.iredmail.com/iRedMail-0.8.7.tar.bz2 tar xvf iRedMail-0.8.7. ...

  7. MySQL常用处理方法

    1.replace into replace into t(id, update_time) values(1, now());或 replace into t(id, update_time) se ...

  8. SuperMap开发入门1——资源下载

    前言(废话) 由于项目需要,我们将被改用超图(SuperMap)平台进行GIS开发.记忆中,我还是在学生时代使用过超图软件5.0版本,安装包只有50M,这也是超图与学校有合作关系的缘故. 在以后的学习 ...

  9. oj

    https://github.com/zhblue/hustoj insert into privilege(user_id,rightstr) values('wxy','administrator ...

  10. eclipse 使用总结

    1.eclipse 运行简单JAVA程序事例 2.eclipse 安装lombok 3.eclipse 远程调试程序 4.eclipse 经常弹出提示框 5.eclipse 修改设置Ctrl+Shif ...