Skip to content

Commit fa01846

Browse files
committed
Gated out the iOS 26 specific APIs
1 parent 8cdffa5 commit fa01846

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

TORoundedButton/TORoundedButton.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
NS_ASSUME_NONNULL_BEGIN
2626

2727
@class TORoundedButton;
28-
@class UICornerConfiguration;
2928

3029
NS_SWIFT_NAME(RoundedButtonDelegate)
3130
@protocol TORoundedButtonDelegate <NSObject>
@@ -42,9 +41,11 @@ IB_DESIGNABLE @interface TORoundedButton : UIControl
4241
/// A delegate object that can receive tap events from this button.
4342
@property (nonatomic, weak) id<TORoundedButtonDelegate> delegate;
4443

44+
#ifdef __IPHONE_26_0
4545
/// The corner-rounding behaviour of the button's boundaries.
4646
/// On iOS 26 and above, this is the `.capsule` preset by default.
4747
@property (nonatomic, strong, nullable) UICornerConfiguration *cornerConfiguration API_AVAILABLE(ios(26.0));
48+
#endif
4849

4950
/// The radius of the corners of this button.
5051
/// (Default is 12.0f on iOS 18 and below. For iOS 26.0, changing this property will update `cornerConfiguration`.)

TORoundedButton/TORoundedButton.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ - (void)_roundedButtonCommonInit TOROUNDEDBUTTON_OBJC_DIRECT {
134134
[self addTarget:self action:@selector(_didDragInside) forControlEvents:UIControlEventTouchDragEnter];
135135

136136
// Set the corner radius depending on app version
137+
#ifdef __IPHONE_26_0
137138
if (@available(iOS 26.0, *)) {
138139
self.cornerConfiguration = [UICornerConfiguration capsuleConfiguration];
139140
} else {
140141
_cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 12.0f;
141142
}
143+
#else
144+
_cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 12.0f;
145+
#endif
142146
}
143147

144148
- (void)_makeTitleLabelIfNeeded TOROUNDEDBUTTON_OBJC_DIRECT {
@@ -518,22 +522,28 @@ - (void)setCornerRadius:(CGFloat)cornerRadius {
518522

519523
_cornerRadius = cornerRadius;
520524

525+
#ifdef __IPHONE_26_0
521526
if (@available(iOS 26.0, *)) {
522527
UICornerRadius *const radius = [UICornerRadius fixedRadius:_cornerRadius];
523528
_backgroundView.cornerConfiguration = [UICornerConfiguration configurationWithUniformRadius:radius];
524529
} else {
525530
_backgroundView.layer.cornerRadius = _cornerRadius;
526531
}
532+
#else
533+
_backgroundView.layer.cornerRadius = _cornerRadius;
534+
#endif
527535
[self setNeedsLayout];
528536
}
529537

538+
#ifdef __IPHONE_26_0
530539
- (void)setCornerConfiguration:(UICornerConfiguration *)cornerConfiguration {
531540
_backgroundView.cornerConfiguration = cornerConfiguration;
532541
}
533542

534543
- (UICornerConfiguration *)cornerConfiguration {
535544
return _backgroundView.cornerConfiguration;
536545
}
546+
#endif
537547

538548
- (void)setIsTranslucent:(BOOL)isTranslucent {
539549
if (_isTranslucent == isTranslucent) {

0 commit comments

Comments
 (0)