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];
}
}