您的位置:首页 > 产品设计 > UI/UE

手势 UILongPressGestureRecognizer 长按手势

2014-09-18 00:00 295 查看
UILongPressGestureRecognizer * longPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(handleLongpressGesture:)];

设置长按手势触发的时间

longPressGesture.minimumPressDuration = 1;

[redView addGestureRecognizer:longPressGesture];

[longPressGesture release];

长按手势 可能会触发两次 (开始接触 和 结束接触 ) 所以 长按手势要判断状态

- (void)handleLongpressGesture :(UILongPressGestureRecognizer *)longPressGesture
{
当识别到长按手势时触发(长按时间到达之后触发)
if (UIGestureRecognizerStateBegan ==longPressGesture.state) {
longPressGesture.view.backgroundColor = [UIColor random];
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息