Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Commit 91a227c

Browse files
codeman7material-automation
authored andcommitted
#Button Update buttons to not fully round corners on press.
PiperOrigin-RevId: 751069425
1 parent 7c19c19 commit 91a227c

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

components/M3CButton/src/M3CButton.m

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,26 @@ - (void)layoutSubviews {
565565

566566
- (void)setCapsuleCornersBasedOn:(CGSize)size {
567567
if (self.isCapsuleShape) {
568-
if (_buttonSizeSet) {
569-
CGFloat height = MIN(size.height, _visualContentSize.height);
570-
CGFloat width = MIN(size.width, _visualContentSize.width);
571-
self.visualBackground.layer.cornerRadius = MIN(height, width) / 2;
572-
self.visualBackground.layer.cornerCurve = kCACornerCurveCircular;
573-
self.layer.cornerRadius = self.visualBackground.layer.cornerRadius;
574-
self.layer.cornerCurve = self.visualBackground.layer.cornerCurve;
568+
if (@available(iOS 15.0, *)) {
569+
if (_buttonSizeSet) {
570+
if (self.isHighlighted && _pressedCornerRadius[@(self.buttonSize)] != nil) {
571+
self.visualBackground.layer.cornerRadius =
572+
[_pressedCornerRadius[@(self.buttonSize)] floatValue];
573+
self.visualBackground.layer.cornerCurve = kCACornerCurveCircular;
574+
self.layer.cornerRadius = self.visualBackground.layer.cornerRadius;
575+
self.layer.cornerCurve = self.visualBackground.layer.cornerCurve;
576+
} else {
577+
CGFloat height = MIN(size.height, _visualContentSize.height);
578+
CGFloat width = MIN(size.width, _visualContentSize.width);
579+
self.visualBackground.layer.cornerRadius = MIN(height, width) / 2;
580+
self.visualBackground.layer.cornerCurve = kCACornerCurveCircular;
581+
self.layer.cornerRadius = self.visualBackground.layer.cornerRadius;
582+
self.layer.cornerCurve = self.visualBackground.layer.cornerCurve;
583+
}
584+
} else {
585+
self.layer.cornerRadius = size.height / 2;
586+
self.layer.cornerCurve = kCACornerCurveCircular;
587+
}
575588
} else {
576589
self.layer.cornerRadius = size.height / 2;
577590
self.layer.cornerCurve = kCACornerCurveCircular;

0 commit comments

Comments
 (0)