1 // 1.创建手势识别器 2 UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] init]; 3 // 1.1设置长按手势识别器的属性 4 // longPress.minimumPressDuration = 5; 5 6 // 手指按下后事件响应之前允许手指移动的偏移位 7 longPress.allowableMovement = 50; 8 9 10 // 2.添加手势识别器到View 11 [self.customView addGestureRecognizer:longPress]; 12 13 // 3.监听手势识别器 14 [longPress addTarget:self action:@selector(longPressView)]; 15 } 16 17 -(void)longPressView 18 { 19 NSLog(@"长按事件"); 20 }