Skip to content

Commit 2b34d46

Browse files
authored
Merge pull request #624 from colbylim/main
Fix toolbar list button alignment issues in iOS26.
2 parents 48f29f6 + 189fc0c commit 2b34d46

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

Objective-C/TOCropViewController/Views/TOCropToolbar.m

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -346,27 +346,16 @@ - (void)layoutToolbarButtons:(NSArray<UIButton *> *)buttons withSameButtonSize:(
346346

347347
if (@available(iOS 26.0, *)) {
348348
CGFloat glassPadding = 6.0f;
349-
CGFloat minSpacing = 16.0f;
350-
CGFloat minPadding = 12.0f;
351-
CGFloat maxExtent = 0.0f;
352-
353-
// On iPad, we'll align in the middle. On iPhone, we'll stretch between Done and Cancel.
354-
if (self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact ||
355-
self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact) {
356-
CGFloat containerExtent = horizontally ? containerRect.size.width : containerRect.size.height;
357-
maxExtent = containerExtent - (minSpacing * 2.0f);
358-
} else {
359-
maxExtent = buttons.count * buttonSize + (minPadding * (buttons.count - 1)) + (glassPadding * 2.0f);
360-
}
361-
349+
CGFloat buttonPadding = 12.0f;
350+
CGFloat maxExtent = buttons.count * buttonSize + (buttonPadding * (buttons.count - 1)) + (glassPadding * 2.0f);
351+
362352
CGRect glassFrame = CGRectZero;
363353
glassFrame.size.width = horizontally ? maxExtent : buttonSize;
364354
glassFrame.size.height = horizontally ? buttonSize : maxExtent;
365355
glassFrame.origin.x = horizontally ? CGRectGetMidX(containerRect) - (glassFrame.size.width / 2.0f) : 0.0f;
366356
glassFrame.origin.y = horizontally ? 0.0f : CGRectGetMidY(containerRect) - (glassFrame.size.height / 2.0f);
367357
_glassView.frame = glassFrame;
368-
369-
CGFloat buttonPadding = (maxExtent - (glassPadding * 2.0f) - (buttons.count * buttonSize)) / (buttons.count - 1);
358+
370359
CGFloat position = glassPadding;
371360
for (UIButton *button in buttons) {
372361
CGRect buttonFrame = CGRectMake(0.0, 0.0, buttonSize, buttonSize);

0 commit comments

Comments
 (0)