1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #import "GreenView.h"
@implementation GreenView
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { NSLog(@"%s",__func__); }
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
//把自己的点转换为按钮坐标系上的点 CGPoint buttonPoint=[self convertPoint:point toView:_button]; if ([_button pointInside:buttonPoint withEvent:event]) { return nil; } return [super hitTest:point withEvent:event]; } - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { CGPoint buttonPoint=[self convertPoint:point toView:_button]; if ([_button pointInside:buttonPoint withEvent:event]) { return NO; } return [super pointInside:point withEvent:event]; } @end
|