版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_18683985/article/details/83990185
UISwipeGestureRecognizer作为iOS中的侧滑手势其实是用的比较多的一个手势.侧滑手势相较于Pan拖动手势来说.一些特殊的方法啊,属性啊,统统木有.打开头文件也只有简洁的两个属性
@property(nonatomic) NSUInteger numberOfTouchesRequired __TVOS_PROHIBITED; // default is 1. the number of fingers that must swipe
@property(nonatomic) UISwipeGestureRecognizerDirection direction; // default is UISwipeGestureRecognizerDirectionRight. the desired direction of the swipe. multiple directions may be specified if they will result in the same behavior (for example, UITableView swipe delete)
以及一个方向的枚举
typedef NS_OPTIONS(NSUInteger, UISwipeGestureRecognizerDirection) {
UISwipeGestureRecognizerDirectionRight = 1 << 0,
UISwipeGestureRecognizerDirectionLeft = 1 << 1,
UISwipeGestureRecognizerDirectionUp = 1 << 2,
UISwipeGestureRecognizerDirectionDown = 1 << 3
};
属性 | 默认值 | 说明 |
---|---|---|
numberOfTouchesRequired | 1 | 默认一个手指头滑动就行,设置为几就需要有一个手指头滑动才能触发滑动手势 |
direction | UISwipeGestureRecognizerDirectionRight | 向右滑 |
枚举值 | 说明 |
---|---|
UISwipeGestureRecognizerDirectionRight | 向右滑 |
UISwipeGestureRecognizerDirectionLeft | 向左滑 |
UISwipeGestureRecognizerDirectionUp | 向上滑 |
UISwipeGestureRecognizerDirectionDown | 向下滑 |
注:侧滑手势容易与pan手势冲突,建议pan手势对象使用
requireGestureRecognizerToFail:
来避免手势冲突