Created
July 5, 2018 09:49
-
-
Save leilee/780d8a18891478cc864153a868148c6b 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
//override this in a UIView Custom Class | |
// check if any sub element inside view is outside bounds of the view | |
// if yes, expand the hitable area of view with its sub element | |
// http://stackoverflow.com/questions/11770743/capturing-touches-on-a-subview-outside-the-frame-of-its-superview-using-hittest | |
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event | |
{ | |
if (!self.clipsToBounds && !self.hidden && self.alpha > 0) { | |
for (UIView *subview in self.subviews.reverseObjectEnumerator) { | |
CGPoint subPoint = [subview convertPoint:point fromView:self]; | |
UIView *result = [subview hitTest:subPoint withEvent:event]; | |
if (result != nil) { | |
return result; | |
} | |
} | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment