Skip to content

Instantly share code, notes, and snippets.

@rydermackay
Created February 25, 2015 23:32
Show Gist options
  • Save rydermackay/56cf9eb51cd5ddaec5d6 to your computer and use it in GitHub Desktop.
Save rydermackay/56cf9eb51cd5ddaec5d6 to your computer and use it in GitHub Desktop.
UIButton that lies about its bounds
@interface MinimumViableButton : UIButton
@end
@implementation MinimumViableButton
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
BOOL result = [super pointInside:point withEvent:event];
if (!result) {
const CGFloat length = 44;
CGRect rect = CGRectInset(self.bounds, MIN(0, (CGRectGetWidth(self.bounds) - length) * 0.5), MIN(0, (CGRectGetHeight(self.bounds) - length) * 0.5));
result = CGRectContainsPoint(rect, point);
}
return result;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment