This file contains 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
.my-button { @include mdc-button-shape-radius(4px); } |
This file contains 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
MDCButton *button = [[MDCButton alloc] init]; | |
MDCRectangleShapeGenerator *rectShape = [[MDCRectangleShapeGenerator alloc] init]; | |
[rectShape setCorners:[MDCCutCornerTreatment alloc] initWithCut:4]]]; | |
button.shapeGenerator = rectShape; |
This file contains 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
FlatButton( | |
shape: BeveledRectangleBorder( | |
// Despite referencing circles and radii, this means "make all corners 4.0". | |
borderRadius: BorderRadius.all(Radius.circular(4.0)), | |
), |
This file contains 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
button.background as? MaterialShapeDrawable?.let { | |
it.shapeAppearanceModel.apply { | |
cornerFamily = CutCornerTreatment(cornerSize) | |
} | |
} |
This file contains 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
<com.google.android.material.button.MaterialButton | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
app:shapeAppearanceOverlay="@style/MyShapeAppearanceOverlay"/> | |
<style name="MyShapeAppearanceOverlay"> | |
<item name="cornerFamily">cut</item> | |
<item name="cornerSize">4dp</item> | |
<style> |
This file contains 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
- (void)updateInkForShape { | |
CGRect boundingBox = CGPathGetBoundingBox(self.layer.shapeLayer.path); | |
self.inkView.maxRippleRadius = | |
(CGFloat)(MDCHypot(CGRectGetHeight(boundingBox), CGRectGetWidth(boundingBox)) / 2 + 10.f); | |
self.inkView.layer.masksToBounds = NO; | |
} |
This file contains 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
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | |
if (self.layer.shapeGenerator) { | |
if (CGPathContainsPoint(self.layer.shapeLayer.path, nil, point, true)) { | |
return self; | |
} else { | |
return nil; | |
} | |
} | |
return [super hitTest:point withEvent:event]; | |
} |
This file contains 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
- (MDCPathGenerator *)pathGeneratorForCornerWithAngle:(CGFloat)angle | |
andRadius:(CGFloat)radius { | |
MDCPathGenerator *path = | |
[MDCPathGenerator pathGeneratorWithStartPoint:CGPointMake(0, radius)]; | |
[path addArcWithTangentPoint:CGPointZero | |
toPoint:CGPointMake(MDCSin(angle) * radius, MDCCos(angle) * radius) | |
radius:radius]; | |
return path; | |
} |
This file contains 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
- (MDCPathGenerator *)pathGeneratorForCornerWithAngle:(CGFloat)angle | |
andCut:(CGFloat)cut { | |
MDCPathGenerator *path = | |
[MDCPathGenerator pathGeneratorWithStartPoint:CGPointMake(0, cut)]; | |
[path addLineToPoint:CGPointMake(MDCSin(angle) * cut, MDCCos(angle) * cut)]; | |
return path; | |
} |
This file contains 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
/** | |
An MDCShapeGenerating for creating shaped rectangular CGPaths. | |
By default MDCRectangleShapeGenerator creates rectangular CGPaths. | |
Set the corner and edge treatments to shape parts of the generated path. | |
*/ | |
@interface MDCRectangleShapeGenerator : NSObject <MDCShapeGenerating> | |
/** | |
The corner treatments to apply to each corner. |
NewerOlder