Created
August 26, 2016 13:58
-
-
Save canapio/61d3659369956c22a9b944a71f36fb6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | |
if (!self.isUserInteractionEnabled || self.isHidden || self.alpha <= 0.01) { | |
return nil; | |
} | |
CGRect touchRect = CGRectInset(self.bounds, -10, -10); | |
if (CGRectContainsPoint(touchRect, point)) { | |
for (UIView *subview in [self.subviews reverseObjectEnumerator]) { | |
CGPoint convertedPoint = [subview convertPoint:point fromView:self]; | |
UIView *hitTestView = [subview hitTest:convertedPoint withEvent:event]; | |
if (hitTestView) { | |
return hitTestView; | |
} | |
} | |
return self; | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment