美文网首页
UIGestureRecognizer类常用属性以及方法

UIGestureRecognizer类常用属性以及方法

作者: anny_4243 | 来源:发表于2021-08-24 10:19 被阅读0次

UIGestureRecognizer类虽然是一个抽象类,但是其中定义了其子手势类中可以通用的方法和属性。下面的几个方法是需要程序员重点掌握的。初始化手势对象并设置手势发生时调用的方法。

- (instancetype)initWithTarget:(nullable id)target action:(nullable SEL)action 

获取手势点击的位置。

- (CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(nullable UIView*)view;

获取手势点击的状态和视图。

@property(nonatomic,readonly) UIGestureRecognizerState state;

其中,常用的UIGestureRecognizerState有以下几个。
◆ UIGestureRecognizerStateBegan:开始手势事件。
◆ UIGestureRecognizerStateEnded:结束手势事件。
◆ UIGestureRecognizerStateChanged:手势位置发生变化。
◆ UIGestureRecognizerStateFailed:无法识别的手势。

手势事件对应的视图对象。

@property(nullable, nonatomic,readonly) UIView *view;

摘自《iOS开发:从零基础到精通》

相关文章

网友评论

      本文标题:UIGestureRecognizer类常用属性以及方法

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