手势识别器
iOS 手势识别器(UIGestureRecognizer)
- 点击手势(UITapGestureRecognizer)
- 滑动手势(UISwipeGestureRecognizer)
- 旋转手势(UIRotationGestureRecognizer)
- 捏合手势( UIPinchGestureRecognizer)
- 长按手势( UILongPressGestureRecognizer)
- 平移手势( UIPanGestureRecognizer)
- 屏幕边缘平移手势(UIScreenEdgePanGestureRecognizer)
UIGestureRecognizer
其相应的方法:
- initWithTarget:action:
- addTarget:action:
- removeTarget:action:
- locationInView:
- locationOfTouch:inView:
- numberOfTouches
属性:
- requireGestureRecognizerToFail:(eg: 单击须要双击失败)
UITapGestureRecognizer
- numberofTapsRequired (点击的次数)
- numberOfTouchesRequired (用的是几根手指)
UISwipeGestureRecognizer
- direction (移动的方向)
- numberOfTouchesRequired
UIRotationGestureRecognizer
- rotation (这里是旋转角度的绝对值,不是增量值,假设须要增量值,须要每次 rotation 置 0)
- velocity (每秒多少弧长, radius 为 1 )
UIPinchGestureRecognizer
- scale (假设 须要获得增量值,也须要 scale 置 1)
- velocity (每秒多少 scale)
UILongPressGestureRecognizer
- minimumPressDuration
- numberOfTouchesRequired
- numberOfTapsRequired
- alowableMovement(同意移动)
UIPanGestureRecognizer
- maximumNumberOfTouches
- minimumNumberOfTouches
- translationinView:
- setTranslation:inView:
- velocityView: (速度以 CGpoint 方式返回,能够分解为 x 和 y 两个方向的速度 )
UIScreenEdgePanGestureRecognizer
>
这个手势与平移手势有些不同,它是以屏幕边缘的部分才干产生效果,一般使用时须要特殊处理,否则就会与平移手势产生冲突.由于它继承 UIPanGestureRecognizer