Created
October 25, 2012 09:55
-
-
Save ksm/3951742 to your computer and use it in GitHub Desktop.
Enlarge tappable area of a UIView
This file contains hidden or 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
// Source: WWDC 2012 Session 216 | |
// Advanced Appearance Customization on iOS | |
// Rather useful when your button is smaller than the golden 44 points | |
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event | |
{ | |
CGFloat widthDelta = 44.0 - bounds.size.width; | |
CGFloat heightDelta = 44.0 - bounds.size.height; | |
CGRect bounds = CGRectInset(self.bounds, -0.5 * widthDelta, -0.5 * heightDelta); | |
return CGRectContainsPoint(bounds, point); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment