From 0dd095fd3e9182d4589c9b46a957dbe6bf26fd66 Mon Sep 17 00:00:00 2001 From: Today Date: Mon, 27 Oct 2025 11:52:26 +0800 Subject: [PATCH] Fix toolbar corved on iPadOS26 top-left windowingControl area. --- .../TOCropViewController/TOCropViewController.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Objective-C/TOCropViewController/TOCropViewController.m b/Objective-C/TOCropViewController/TOCropViewController.m index 8816a219..aed868e8 100755 --- a/Objective-C/TOCropViewController/TOCropViewController.m +++ b/Objective-C/TOCropViewController/TOCropViewController.m @@ -282,6 +282,17 @@ - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures - (CGRect)frameForToolbarWithVerticalLayout:(BOOL)verticalLayout { UIEdgeInsets insets = self.statusBarSafeInsets; + + // fix: On iOS 26, overlay with iPadOS windowingControl area. + if (@available(iOS 26.0, *)) { + if (!verticalLayout) { + UIViewLayoutRegion *layoutRegion = [UIViewLayoutRegion safeAreaLayoutRegionWithCornerAdaptation: UIViewLayoutRegionAdaptivityAxisVertical]; + UIEdgeInsets edgeInsets = [self.view edgeInsetsForLayoutRegion:layoutRegion]; + insets.top = edgeInsets.top; + insets.left = edgeInsets.left; + insets.bottom = edgeInsets.bottom; + } + } CGRect frame = CGRectZero; if (!verticalLayout) { // In landscape laying out toolbar to the left @@ -291,10 +302,10 @@ - (CGRect)frameForToolbarWithVerticalLayout:(BOOL)verticalLayout #else CGFloat minPadding = 16.0f; #endif - frame.origin.x = insets.left + minPadding; - frame.origin.y = minPadding; + frame.origin.x = insets.left; + frame.origin.y = minPadding + insets.top; frame.size.width = kTOCropViewControllerToolbarHeight; - frame.size.height = CGRectGetHeight(self.view.frame) - (minPadding * 2.0f); + frame.size.height = CGRectGetHeight(self.view.frame) - (minPadding * 2.0f) - insets.top - insets.bottom; } else { frame.origin.x = insets.left; frame.origin.y = 0.0f;