hitTest

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    //把自己的点转成控件坐标系上的点
    CGPoint currentPoint = [self convertPoint:point toView:self];
    
    if ([_button pointInside:currentPoint withEvent:event]) {
        return nil;
    }
    
    return [super hitTest:point withEvent:event];
    
}


- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    CGPoint currentPoint = [self convertPoint:point toView:self];
    
    if ([_button pointInside:currentPoint withEvent:event]) {
        return NO;
    }
    return [super pointInside:point withEvent:event];
}


你可能感兴趣的:(hitTest)