iOS开发UI高级手势识别器

Posted SessionOne

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS开发UI高级手势识别器相关的知识,希望对你有一定的参考价值。

####手势识别器
UIGestureRecognizer类

·UITapGestureRecognizer(轻击)

·UIPinchGestureRecognizer(捏合)

·UIPanGestureRecognizer(平移) 事实调用

·UISwipeGestureRecognizer(轻扫)

·UIRotationGestureRecognizer(旋转)

·UILongPressGestureRecognizer(长按)

alloc initwithTar
[singleTap requireGestureRecognizerToFail:doubleTap];

####具体实现
//1 单击
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
[imageV addGestureRecognizer:tap];

//2 双击
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction1:)];
//点击的次数
doubleTap.numberOfTapsRequired = 2;
[imageV addGestureRecognizer:doubleTap];

//双击失败是单击 ---->双击成功,单击不算
[tap requireGestureRecognizerToFail:doubleTap];

//3 长按
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];
[imageV addGestureRecognizer:longPress];


//4 轻扫
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeAction:)];
//属性:轻扫方向
swipe.direction = UISwipeGestureRecognizerDirectionRight;
[imageV addGestureRecognizer:swipe];

//5 移动 实时调用
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];
[imageV addGestureRecognizer:pan];

//轻扫失败算移动--->轻扫成功 移动失败
[pan requireGestureRecognizerToFail:swipe];


//6 旋转
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(totationAction:)];
[imageV addGestureRecognizer:rotation];


//7 捏合
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchAction:)];
[imageV addGestureRecognizer:pinch];

以上是关于iOS开发UI高级手势识别器的主要内容,如果未能解决你的问题,请参考以下文章

iOS开发之手势识别汇总

iOS开发中六种手势识别

iOS开发之手势识别

ios开发手势处理之手势识别二

Hololens开发笔记之Gesture手势识别(基本介绍)

ios开发之手势处理 之手势识别一