@@ -50,12 +50,17 @@ @implementation TORoundedButton {
5050
5151 /* * A background view that displays the rounded box behind the button text. */
5252 UIView *_backgroundView;
53+
54+ #ifdef __IPHONE_26_0
55+ /* * Maintain a reference to the corner configuration in case we swap out the background view */
56+ UICornerConfiguration *_cornerConfiguration API_AVAILABLE (ios (26.0 ));
57+ #endif
5358}
5459
5560#pragma mark - View Creation -
5661
5762- (instancetype )init {
58- if (self = [self initWithFrame: (CGRect){0 ,0 , 288 .0f , 44 .0f }]) { }
63+ if (self = [self initWithFrame: (CGRect){0 ,0 , 288 .0f , 52 .0f }]) { }
5964 return self;
6065}
6166
@@ -86,7 +91,7 @@ - (instancetype)initWithContentView:(__kindof UIView *)contentView {
8691}
8792
8893- (instancetype )initWithText : (NSString *)text {
89- if (self = [super initWithFrame: (CGRect){0 ,0 , 288 .0f , 44 .0f }]) {
94+ if (self = [super initWithFrame: (CGRect){0 ,0 , 288 .0f , 52 .0f }]) {
9095 _contentView = [UIView new ];
9196 [self _roundedButtonCommonInit ];
9297 [self _makeTitleLabelIfNeeded ];
@@ -105,6 +110,18 @@ - (void)_roundedButtonCommonInit TOROUNDEDBUTTON_OBJC_DIRECT {
105110 _tappedTintColorBrightnessOffset = !TO_ROUNDED_BUTTON_FLOAT_IS_ZERO (_tappedTintColorBrightnessOffset) ?: -0 .15f ;
106111 _contentInset = (UIEdgeInsets){15.0 , 15.0 , 15.0 , 15.0 };
107112 _blurStyle = UIBlurEffectStyleDark;
113+
114+ // Set the corner radius depending on system version
115+ #ifdef __IPHONE_26_0
116+ if (@available (iOS 26.0 , *)) {
117+ _cornerConfiguration = [UICornerConfiguration capsuleConfiguration ];
118+ } else {
119+ _cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 12 .0f ;
120+ }
121+ #else
122+ _cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 12 .0f ;
123+ #endif
124+
108125#ifdef __IPHONE_13_0
109126 if (@available (iOS 13.0 , *)) { _blurStyle = UIBlurEffectStyleSystemThinMaterialDark; }
110127#endif
@@ -132,17 +149,6 @@ - (void)_roundedButtonCommonInit TOROUNDEDBUTTON_OBJC_DIRECT {
132149 [self addTarget: self action: @selector (_didTouchUpInside ) forControlEvents: UIControlEventTouchUpInside];
133150 [self addTarget: self action: @selector (_didDragOutside ) forControlEvents: UIControlEventTouchDragExit|UIControlEventTouchCancel];
134151 [self addTarget: self action: @selector (_didDragInside ) forControlEvents: UIControlEventTouchDragEnter];
135-
136- // Set the corner radius depending on app version
137- #ifdef __IPHONE_26_0
138- if (@available (iOS 26.0 , *)) {
139- self.cornerConfiguration = [UICornerConfiguration capsuleConfiguration ];
140- } else {
141- _cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 12 .0f ;
142- }
143- #else
144- _cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 12 .0f ;
145- #endif
146152}
147153
148154- (void )_makeTitleLabelIfNeeded TOROUNDEDBUTTON_OBJC_DIRECT {
@@ -176,6 +182,15 @@ - (UIView *)_makeBackgroundViewWithBlur:(BOOL)withBlur TOROUNDEDBUTTON_OBJC_DIRE
176182 }
177183 backgroundView.frame = self.bounds ;
178184 backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
185+
186+ #ifdef __IPHONE_26_0
187+ if (@available (iOS 26.0 , *)) {
188+ backgroundView.cornerConfiguration = _cornerConfiguration;
189+ } else {
190+ backgroundView.layer .cornerRadius = _cornerRadius;
191+ }
192+ #endif
193+
179194#ifdef __IPHONE_13_0
180195 if (@available (iOS 13.0 , *)) { backgroundView.layer .cornerCurve = kCACornerCurveContinuous ; }
181196#endif
@@ -525,7 +540,8 @@ - (void)setCornerRadius:(CGFloat)cornerRadius {
525540#ifdef __IPHONE_26_0
526541 if (@available (iOS 26.0 , *)) {
527542 UICornerRadius *const radius = [UICornerRadius fixedRadius: _cornerRadius];
528- _backgroundView.cornerConfiguration = [UICornerConfiguration configurationWithUniformRadius: radius];
543+ _cornerConfiguration = [UICornerConfiguration configurationWithUniformRadius: radius];
544+ _backgroundView.cornerConfiguration = _cornerConfiguration;
529545 } else {
530546 _backgroundView.layer .cornerRadius = _cornerRadius;
531547 }
@@ -537,11 +553,12 @@ - (void)setCornerRadius:(CGFloat)cornerRadius {
537553
538554#ifdef __IPHONE_26_0
539555- (void )setCornerConfiguration : (UICornerConfiguration *)cornerConfiguration {
540- _backgroundView.cornerConfiguration = cornerConfiguration;
556+ _cornerConfiguration = cornerConfiguration;
557+ _backgroundView.cornerConfiguration = _cornerConfiguration;
541558}
542559
543560- (UICornerConfiguration *)cornerConfiguration {
544- return _backgroundView. cornerConfiguration ;
561+ return _cornerConfiguration ;
545562}
546563#endif
547564
0 commit comments