iOS菜鸟食谱

侧滑菜单我用到的UIPanGesture两个方法

2015-12-11  本文已影响567人  月咏蝴蝶

UIPanGestureRecognizer

maximumNumberOfTouches :最大触摸的数量
minimumNumberOfTouches :最少触摸的数量

CGPoint translantion = [UIPanGestureRecognizer translationInView:UIView];
ABS(translantion.x)/ABS(translantion.y) > 1

即是判断是否水平移动(x轴拖动距离大于y轴拖动距离)

CGPoint velocity = [UIPanGestureRecognizer velocityInView:UIView];
velocity.x > 0

即是判断是否向右滑动的速度是否大于0

另外顺便记记其他手势基本姿势

typedef enum {
  
UISwipeGestureRecognizerDirectionRight = 1 << 0,
   
UISwipeGestureRecognizerDirectionLeft  = 1 << 1,
   
UISwipeGestureRecognizerDirectionUp    = 1 << 2,
  
UISwipeGestureRecognizerDirectionDown  = 1 << 3

} UISwipeGestureRecognizerDirection;

numberOfTouchesRequired : 触点的数量,默认值为1,即手指数

上一篇 下一篇

猜你喜欢

热点阅读