1、手势识别器——UIGestureRecognizer 介绍
在ios开发中,除了有关触摸的这组方法来控制使用用者的手指触控外,还可以用UIGestureRecognizer的衍生类来进行判断。
用UIGestureRecognizer的好处在于有现成的手势,开发者不用自己计算手指移动轨迹,创建了这些手势识别器之后可以调用视图的addGestureRecognizer:方法,将手势识别器注册到某个视图组件上。
UIGestureRecognizer是在Touch的基础上封装出来的。
UIGestureRecognizer的子类类别有以下几种:
- UIPanGestureRecognizer(拖动识别器)
- UIPinchGestureRecognizer(捏合识别器)
- UIRotationGestureRecognizer(旋转识别器)
- UITapGestureRecognizer(轻拍识别器)
- UILongPressGestureRecognizer(长按识别器)
- UISwipeGestureRecognizer(扫动识别器)