标签:
***hitTest 获取最合适的点
@implementation HMGreenView - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"%s",__func__); } // 获取 最合适的 点的view //- (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]; // 从右边这个view上的点转换为坐标上的点 CGPoint buttonPoint =[_button convertPoint:point fromView:self]; if ([_button pointInside:buttonPoint withEvent:event]) return NO; //自己不是最合适的点 return [super pointInside:point withEvent:event]; } @end
标签:
原文地址:http://www.cnblogs.com/ios-g/p/4773175.html