实现事件冒泡
1. 触摸事件响应链
2. 实现触摸事件
// 自定义 UIView
@interface CustomView : UIView
@end
@implementation CustomView
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
NSLog(@"CustomView touchesBegan");
[super touchesBegan:touches withEvent:event]; // 调用父类的方法
}
@end3. 传递触摸事件
4. 注意事项
5. 示例
总结
Last updated