UI手势

作者: 爱吃芒果的淼小猪 | 来源:发表于2016-02-20 11:09 被阅读0次

手势:有规律的触摸

UIGestureRecognizer抽象类

七种手势:轻拍(tap)长按(longPress)旋转(rotation)捏合(pinch)拖拽(pan)清扫(swipe)屏幕边缘拖拽(screenEdgePan)

//添加手势

[imgView addGestureRecongnizer:tap];

//内存管理

[top release];

//长按(longPress)

UILongPressGestureRecongnizer *longPress = [UILongPressGestureRecognizer alloc]initwithTarget:Self action:@selector(longPressAction:)];                                                                                                                           [ longPress release];

//长按时间

longPress.minimumPressDuration = 1;

//旋转(rotation)

UIRotationGestureRecognizer *rotation = [UIRotationGestureRecongnizer alloc]initWithTarget:selfaction:@selector(pinchAction:)];                                                                                        [imgView addGestureRecognizer:pinch];                                                                                                                [pinch release];

 // UIView transform属性 专门用来进行形变(位置position/旋转rotation/缩放scale)设置

   // 获取当前手势触发的视图

   UIImageView *imgView = (UIImageView *)rotation.view;

   // 设置transfrom实现旋转

   imgView.transform = CGAffineTransformMakeRotation(rotation.rotation);

//拖拽(pan)同上

 // 拖拽视图

   UIImageView *imgView = (UIImageView *)pan.view;

   // 获取拖拽时 经过的点

   CGPoint p = [pan translationInView:imgView];

   // 设置transform

   imgView.transform = CGAffineTransformMakeTranslation(p.x, p.y);

//捏合(pinch)同上

// 获取view

   UIImageView *imgView = (UIImageView *)pinch.view;

   // 如果使用makeScale函数 不需要设置比例系数

   imgView.transform = CGAffineTransformMakeScale(pinch.scale, pinch.scale);

//轻扫(swipe)

UISwipeGestureRecognizer *swipe = [UISwipeGestureRecongnizer alloc]initWithTarget:selfaction:@selector(pinchAction:)];

//默认只识别向右                                                                                      

//设置方向时 最多只能设置水平(左/右)或者垂直(上/下)

swipe.direction = UISwipeGestureRecognizerDirectionRight

UISwipeGstureRecognizerDirectionLefet;

[imgView addGestureRecognizer:swipe];  

//屏幕边缘拖拽(screenEdgePan)

UIScreenEdgePanGestureRecognizer *sep = [UIScreenEdgePanGestureRecongnizer alloc]initWithTarget:selfaction:@selector(pinchAction:)];

//需要设置拖拽的边缘

sep.edges = UIRectEdgeLeft;

//一般这个手势添加在VC的view上

[self.view addGestureRecognizer:sep];

[sep release];

相关文章

  • UI总结-手势

    UI总结-手势 常用的6种手势: #import "ViewController.h" @...

  • UI手势

    手势识别器有:轻拍 长按 旋转 捏合 拖拽 清扫 屏幕边缘拖拽 在使用这些手势识别器时 先打开用户交互 image...

  • UI手势

    UIGestureRecongnizer:NSObject 1.-(void)addGestureRecogniz...

  • UI - 手势

    UIGestureRecognizer手势识别器 手势:有规律的触摸 UIGestureRecognizer抽象类...

  • UI手势

    手势:有规律的触摸 UIGestureRecognizer抽象类 七种手势:轻拍(tap)长按(longPress...

  • UI手势

    UIGestureRecognizer手势识别器 手势:有规律的触摸 UIGestureRecognizer抽象类...

  • 5.2 GestureRecognizer---UI手势

    GestureRecognizer---UI手势 基础控制器 导航栏视图控制器, 根试图控制器 单击手势 双击手势...

  • UI梳理——手势

    手势分类: 手势的创建: 方法的实现: 轻扫手势:UISwipeGestureRecognizer 长按手势: 以...

  • UI手势回顾

    UIGestureRecongnizer手势识别器 手势:有规律的触摸 UIGestureRecognizer抽象...

  • UI手势控件

    一、拖拽 示例代码: 复制代码 1 // 2 // YYViewController.m 3 // 06-拖拽事件...

网友评论

      本文标题:UI手势

      本文链接:https://www.haomeiwen.com/subject/vvjukttx.html