Skip to content

Instantly share code, notes, and snippets.

@ksm
Created October 25, 2012 09:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksm/3951742 to your computer and use it in GitHub Desktop.
Save ksm/3951742 to your computer and use it in GitHub Desktop.
Enlarge tappable area of a UIView
// 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