美文网首页
手势的简单封装

手势的简单封装

作者: CHADHEA | 来源:发表于2017-03-10 11:07 被阅读0次

//.h

//单击

+ (void)tapWith:(UIView *)view target:(id)target action:(SEL)action;

//单击 + 双击

+ (void)tapWith:(UIView *)view target:(id)target singleAction:(SEL)singleAction  doubleAction:(SEL)doubleAction;

//拖动

+ (void)panWith:(UIView *)view target:(id)target action:(SEL)action;

//缩放

+ (void)pinchWith:(UIView *)view target:(id)target action:(SEL)action;

//旋转

+ (void)rotationWith:(UIView *)view target:(id)target action:(SEL)action;

//长按

+ (void)longPressWith:(UIView *)view target:(id)target action:(SEL)action;

//滑动

+ (void)swipeWith:(UIView *)view target:(id)target action:(SEL)action;

//.m

//单击

+ (void)tapWith:(UIView *)view target:(id)target action:(SEL)action {

UITapGestureRecognizer  *mzTap = [[UITapGestureRecognizer alloc]initWithTarget:target action:action];

[view addGestureRecognizer:mzTap];

}

//单击 + 双击

+ (void)tapWith:(UIView *)view target:(id)target singleAction:(SEL)singleAction  doubleAction:(SEL)doubleAction {

UITapGestureRecognizer  *mzSingleTap = [[UITapGestureRecognizer alloc]initWithTarget:target action:singleAction];

mzSingleTap.numberOfTapsRequired = 1;

UITapGestureRecognizer  *mzDoubleTap = [[UITapGestureRecognizer alloc]initWithTarget:target action:doubleAction];

mzDoubleTap.numberOfTapsRequired = 2;

[mzSingleTap requireGestureRecognizerToFail:mzDoubleTap];

[view addGestureRecognizer:mzSingleTap];

[view addGestureRecognizer:mzDoubleTap];

}

//拖动

+ (void)panWith:(UIView *)view target:(id)target action:(SEL)action {

UIPanGestureRecognizer  *mzPan = [[UIPanGestureRecognizer alloc]initWithTarget:target action:action];

[view addGestureRecognizer:mzPan];

}

//缩放

+ (void)pinchWith:(UIView *)view target:(id)target action:(SEL)action {

UIPinchGestureRecognizer  *mzPinch = [[UIPinchGestureRecognizer alloc]initWithTarget:target action:action];

[view addGestureRecognizer:mzPinch];

}

//旋转

+ (void)rotationWith:(UIView *)view target:(id)target action:(SEL)action {

UIRotationGestureRecognizer  *mzRotation = [[UIRotationGestureRecognizer alloc]initWithTarget:target action:action];

[view addGestureRecognizer:mzRotation];

}

//长按

+ (void)longPressWith:(UIView *)view target:(id)target action:(SEL)action {

UILongPressGestureRecognizer  *mzLongPress = [[UILongPressGestureRecognizer alloc]initWithTarget:target action:action];

[view addGestureRecognizer:mzLongPress];

}

//滑动

+ (void)swipeWith:(UIView *)view target:(id)target action:(SEL)action {

UISwipeGestureRecognizer  *mzSwipe = [[UISwipeGestureRecognizer alloc]initWithTarget:target action:action];

[view addGestureRecognizer:mzSwipe];

}

相关文章

  • 手势的简单封装

    //.h //单击 + (void)tapWith:(UIView *)view target:(id)targe...

  • iOS Category库工具简单封装介绍

    简单介绍这个库的大致内容:Category各种工具集合,Button图文混排、点击事件封装、扩大点击域,手势封装、...

  • 变形和手势

    添加手势 ViewController.m 手势加变形ViewController.m 封装手势ViewContr...

  • iOS-添加手势(文章结尾有完整代码)

    手势,手势响应GestureRecognizer 关于手势响应IOS中封装了一个类,能响应一般手势UIGestur...

  • 手势

    手势,有规律的触摸事件的封装手势类,抽象类,使用他的子类UIGestureRecognizer 手势识别器 ima...

  • Gesture手势

    手势识别器 手势识别器是对触摸事件做了封装,我们无需自己去判断某个手势是否触发,手势识别器本身起到了识别作用,我们...

  • UIGestureRecognizer

    什么是手势识别器? 手势识别器就是对触摸事件做了封装,我们不需要判断某个手势是否触发,手势识别器本身起到了识别作用...

  • vue2.x plugin vue2-touch

    今天小编想和大家分享一下Vue2.x的手势插件--简单来说就是Hammerjs的vue2.x plugin的封装。...

  • iOS之手势

    手势 手势是一种对触摸事件的封装它是有规律的触摸事件的集合.每一个手势必须被一个对象所接受.同时,每一个手势只能被...

  • android 二维码扫描

    直接效果图 简单的封装了可以直接抄到项目里不用改啥,集成自最新的zxing库。 增加了手势缩放,双击放大/缩小。 ...

网友评论

      本文标题:手势的简单封装

      本文链接:https://www.haomeiwen.com/subject/dxungttx.html