Skip to content

Commit 96adb30

Browse files
authored
Merge pull request #614 from Rk1821389/fix-deprecations
Fix deprecated imageEdgeInsets for iOS 15
2 parents d4a6d81 + 4ec4a19 commit 96adb30

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Objective-C/TOCropViewController/Views/TOCropToolbar.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,20 @@ - (void)layoutToolbarButtons:(NSArray *)buttons withSameButtonSize:(CGSize)size
294294
CGPoint origin = horizontally ? CGPointMake(diffOffset, sameOffset) : CGPointMake(sameOffset, diffOffset);
295295
if (horizontally) {
296296
origin.x += CGRectGetMinX(containerRect);
297-
if (@available(iOS 13.0, *)) {
297+
if (@available(iOS 15.0, *)) {
298+
// iOS 15+: Use UIButtonConfiguration
299+
UIButtonConfiguration *config = button.configuration ?: [UIButtonConfiguration plainButtonConfiguration];
300+
301+
// Position image and text
302+
config.imagePlacement = NSDirectionalRectEdgeLeading;
303+
config.imagePadding = 8;
304+
305+
UIImage *image = button.imageView.image;
306+
config.contentInsets = NSDirectionalEdgeInsetsMake(0, 0, image.baselineOffsetFromBottom, 0);
307+
308+
button.configuration = config;
309+
310+
} else if (@available(iOS 13.0, *)) {
298311
UIImage *image = button.imageView.image;
299312
button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, image.baselineOffsetFromBottom, 0);
300313
}

0 commit comments

Comments
 (0)