Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MRoundedButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern CGFloat const MRoundedButtonMaxValue;
@property (nonatomic, weak) UILabel *detailTextLabel;
@property (nonatomic, weak) UIImageView *imageView;
@property (nonatomic, assign) UIEdgeInsets contentEdgeInsets;
@property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;

+ (instancetype)buttonWithFrame:(CGRect)frame
buttonStyle:(MRoundedButtonStyle)style
Expand Down
13 changes: 13 additions & 0 deletions MRoundedButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_cornerRadius = 0.0;
_borderWidth = 0.0;
_contentEdgeInsets = UIEdgeInsetsZero;
_hitTestEdgeInsets = UIEdgeInsetsZero;

self.foregroundView = [[UIView alloc] initWithFrame:CGRectNull];
self.foregroundView.backgroundColor = self.foregroundColor;
Expand Down Expand Up @@ -401,6 +402,18 @@ - (void)fadeOutAnimation
}

#pragma mark - Touchs

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if (UIEdgeInsetsEqualToEdgeInsets(self.hitTestEdgeInsets, UIEdgeInsetsZero) || !self.enabled || self.hidden) {
return [super pointInside:point withEvent:event];
}
CGRect relativeFrame = self.bounds;
CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, self.hitTestEdgeInsets);

return CGRectContainsPoint(hitFrame, point);
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *touchView = [super hitTest:point withEvent:event];
Expand Down