Skip to content

Commit

Permalink
[MDCButton] Ink should match button frame to be centered properly
Browse files Browse the repository at this point in the history
Summary:
Before/after screenshot: http://codereview.cc/M30

Addresses issue:
https://github.com/google/material-components-ios/issues/475

Reviewers: ajsecord, randallli, #mdc_ios_owners

Reviewed By: randallli, #mdc_ios_owners

Projects: #material_components_ios

Differential Revision: http://codereview.cc/D805
  • Loading branch information
Junius Gunaratne committed May 3, 2016
1 parent dd1b1e0 commit 5ca5458
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/Buttons/src/MDCButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ - (void)layoutSubviews {
self.layer.shadowPath = [self boundingPath].CGPath;
self.layer.cornerRadius = [self cornerRadius];

// Calculate center based on contentEdgeInsets
_inkView.usesCustomInkCenter = YES;
// The ink view frame should match the content rect to be centered correctly. The content rect is
// calculated based on the title, image size and padding; then adjusted based on the control
// content alignment. The button frame cannot be used since it has rect offsets without insets.
CGRect contentRect = [self contentRectForBounds:self.bounds];
_inkView.customInkCenter = CGPointMake(CGRectGetMidX(contentRect), CGRectGetMidY(contentRect));
_inkView.frame = contentRect;
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
Expand Down

0 comments on commit 5ca5458

Please sign in to comment.