美文网首页
UILongPressGestureRecognizer长按手势

UILongPressGestureRecognizer长按手势

作者: 浅_若清风 | 来源:发表于2018-06-01 14:03 被阅读0次

概述:UILongPressGestureRecognizer长按手势,继承于UIGestureRecognizer类。

手势的配置

/*按压的手指数,默认为0*/
@property (nonatomic) NSUInteger numberOfTapsRequired;  
/*按压必须的手指数,默认为1*/
@property (nonatomic) NSUInteger numberOfTouchesRequired __TVOS_PROHIBITED; 
/*按压的最短时间,默认为0.5秒*/
@property (nonatomic) CFTimeInterval minimumPressDuration; 
/*在手势失败之前允许的最大像素移动。一旦确认(在最小压力持续时间之后),手指跟踪的余量没有限制。默认为10*/
@property (nonatomic) CGFloat allowableMovement;    
     

案例

/* 添加长按手势*/
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlelongGesture:)];
longPress.numberOfTapsRequired = 2;
/*定义按的时间*/
longPress.minimumPressDuration = 1.0; 
[self.collectionView addGestureRecognizer:longPress];

/*实现长按手势方法*/
#pragma mark - 长按手势
- (void)handlelongGesture:(UILongPressGestureRecognizer *)longPress
{

}

注:了解UIGestureRecognizer类请跳转https://www.jianshu.com/p/e206dc86f89a

相关文章

网友评论

      本文标题:UILongPressGestureRecognizer长按手势

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