From c21f9dfa2342483903f7c633c7f63424f298c73c Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Sat, 4 Oct 2025 12:27:56 +0900 Subject: [PATCH 1/3] Add macro defines to Xcode 236 specific code --- Objective-C/TOCropViewController/Views/TOCropToolbar.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Objective-C/TOCropViewController/Views/TOCropToolbar.m b/Objective-C/TOCropViewController/Views/TOCropToolbar.m index 7668d226..81383172 100644 --- a/Objective-C/TOCropViewController/Views/TOCropToolbar.m +++ b/Objective-C/TOCropViewController/Views/TOCropToolbar.m @@ -58,6 +58,7 @@ - (void)setup { self.backgroundView = [[UIView alloc] initWithFrame:self.bounds]; UIView *containerView = self; +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_26_0 if (@available(iOS 26.0, *)) { UIGlassEffect *glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear]; glassEffect.interactive = YES; @@ -72,6 +73,10 @@ - (void)setup { self.backgroundView.backgroundColor = [UIColor colorWithWhite:0.12f alpha:1.0f]; [self addSubview:self.backgroundView]; } +#else + self.backgroundView.backgroundColor = [UIColor colorWithWhite:0.12f alpha:1.0f]; + [self addSubview:self.backgroundView]; +#endif // On iOS 9 and up, we can use the new layout features to determine whether we're in an 'Arabic' style language mode _reverseContentLayout = ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft); @@ -103,11 +108,13 @@ - (void)setup { [_doneIconButton setImage:[TOCropToolbar doneImage] forState:UIControlStateNormal]; [_doneIconButton setTintColor:[UIColor colorWithRed:1.0f green:0.8f blue:0.0f alpha:1.0f]]; [_doneIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_26_0 if (@available(iOS 26.0, *)) { UIButtonConfiguration *configuration = [UIButtonConfiguration prominentGlassButtonConfiguration]; configuration.baseForegroundColor = [UIColor blackColor]; _doneIconButton.configuration = configuration; } +#endif [self addSubview:_doneIconButton]; // Set the default color for the done buttons @@ -132,9 +139,11 @@ - (void)setup { _cancelIconButton = [UIButton buttonWithType:UIButtonTypeSystem]; [_cancelIconButton setImage:[TOCropToolbar cancelImage] forState:UIControlStateNormal]; [_cancelIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_26_0 if (@available(iOS 26.0, *)) { _cancelIconButton.configuration = [UIButtonConfiguration clearGlassButtonConfiguration]; } +#endif [self addSubview:_cancelIconButton]; _clampButton = [UIButton buttonWithType:UIButtonTypeSystem]; From 107ce5f41c18c8b4c8c1831e76323784f7d0b70e Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Sat, 4 Oct 2025 12:45:17 +0900 Subject: [PATCH 2/3] Change macro syntax --- Objective-C/TOCropViewController/Views/TOCropToolbar.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objective-C/TOCropViewController/Views/TOCropToolbar.m b/Objective-C/TOCropViewController/Views/TOCropToolbar.m index 81383172..9538286f 100644 --- a/Objective-C/TOCropViewController/Views/TOCropToolbar.m +++ b/Objective-C/TOCropViewController/Views/TOCropToolbar.m @@ -58,7 +58,7 @@ - (void)setup { self.backgroundView = [[UIView alloc] initWithFrame:self.bounds]; UIView *containerView = self; -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_26_0 +#ifdef __IPHONE_26_0 if (@available(iOS 26.0, *)) { UIGlassEffect *glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear]; glassEffect.interactive = YES; @@ -108,7 +108,7 @@ - (void)setup { [_doneIconButton setImage:[TOCropToolbar doneImage] forState:UIControlStateNormal]; [_doneIconButton setTintColor:[UIColor colorWithRed:1.0f green:0.8f blue:0.0f alpha:1.0f]]; [_doneIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_26_0 +#ifdef __IPHONE_26_0 if (@available(iOS 26.0, *)) { UIButtonConfiguration *configuration = [UIButtonConfiguration prominentGlassButtonConfiguration]; configuration.baseForegroundColor = [UIColor blackColor]; @@ -139,7 +139,7 @@ - (void)setup { _cancelIconButton = [UIButton buttonWithType:UIButtonTypeSystem]; [_cancelIconButton setImage:[TOCropToolbar cancelImage] forState:UIControlStateNormal]; [_cancelIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_26_0 +#ifdef __IPHONE_26_0 if (@available(iOS 26.0, *)) { _cancelIconButton.configuration = [UIButtonConfiguration clearGlassButtonConfiguration]; } From 79dbd749c6305f7de161ce69548b90cd1d6caa00 Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Sat, 4 Oct 2025 13:27:07 +0900 Subject: [PATCH 3/3] Updated toolbar layout for visionOS --- .../TOCropViewController.m | 8 +++++++ .../Views/TOCropToolbar.m | 21 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Objective-C/TOCropViewController/TOCropViewController.m b/Objective-C/TOCropViewController/TOCropViewController.m index d26e1ba4..4e5d1ef5 100755 --- a/Objective-C/TOCropViewController/TOCropViewController.m +++ b/Objective-C/TOCropViewController/TOCropViewController.m @@ -286,7 +286,11 @@ - (CGRect)frameForToolbarWithVerticalLayout:(BOOL)verticalLayout CGRect frame = CGRectZero; if (!verticalLayout) { // In landscape laying out toolbar to the left if (@available(iOS 26.0, *)) { +#if !TARGET_OS_VISION CGFloat minPadding = 8.0f; +#else + CGFloat minPadding = 16.0f; +#endif frame.origin.x = insets.left + minPadding; frame.origin.y = minPadding; frame.size.width = kTOCropViewControllerToolbarHeight; @@ -314,6 +318,7 @@ - (CGRect)frameForToolbarWithVerticalLayout:(BOOL)verticalLayout insets.bottom = 8.0f; } +#if !TARGET_OS_VISION const char* components[] = {"Radius", "Corner", "display", "_"}; NSString *selectorName = @""; for (NSInteger i = 3; i >= 0; i--) { @@ -321,6 +326,9 @@ - (CGRect)frameForToolbarWithVerticalLayout:(BOOL)verticalLayout encoding:NSUTF8StringEncoding]]; } const CGFloat cornerRadius = [[UIScreen.mainScreen valueForKey:selectorName] floatValue]; +#else + const CGFloat cornerRadius = 64.0f; +#endif frame.size.width = CGRectGetWidth(self.view.bounds) - MAX(cornerRadius, insets.bottom * 2.0f); } else { frame.size.width = CGRectGetWidth(self.view.bounds); diff --git a/Objective-C/TOCropViewController/Views/TOCropToolbar.m b/Objective-C/TOCropViewController/Views/TOCropToolbar.m index 9538286f..e4215bce 100644 --- a/Objective-C/TOCropViewController/Views/TOCropToolbar.m +++ b/Objective-C/TOCropViewController/Views/TOCropToolbar.m @@ -60,9 +60,16 @@ - (void)setup { UIView *containerView = self; #ifdef __IPHONE_26_0 if (@available(iOS 26.0, *)) { + UIVisualEffect *effect = nil; +#if !TARGET_OS_VISION UIGlassEffect *glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear]; glassEffect.interactive = YES; - _glassView = [[UIVisualEffectView alloc] initWithEffect:glassEffect]; + effect = glassEffect; +#else + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleProminent]; + effect = blurEffect; +#endif + _glassView = [[UIVisualEffectView alloc] initWithEffect:effect]; _glassView.cornerConfiguration = [UICornerConfiguration capsuleConfiguration]; _glassView.userInteractionEnabled = YES; [self addSubview:_glassView]; @@ -108,10 +115,14 @@ - (void)setup { [_doneIconButton setImage:[TOCropToolbar doneImage] forState:UIControlStateNormal]; [_doneIconButton setTintColor:[UIColor colorWithRed:1.0f green:0.8f blue:0.0f alpha:1.0f]]; [_doneIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; -#ifdef __IPHONE_26_0 +#if defined(__IPHONE_26_0) if (@available(iOS 26.0, *)) { +#if !TARGET_OS_VISION UIButtonConfiguration *configuration = [UIButtonConfiguration prominentGlassButtonConfiguration]; configuration.baseForegroundColor = [UIColor blackColor]; +#else + UIButtonConfiguration *configuration = [UIButtonConfiguration filledButtonConfiguration]; +#endif _doneIconButton.configuration = configuration; } #endif @@ -139,9 +150,13 @@ - (void)setup { _cancelIconButton = [UIButton buttonWithType:UIButtonTypeSystem]; [_cancelIconButton setImage:[TOCropToolbar cancelImage] forState:UIControlStateNormal]; [_cancelIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; -#ifdef __IPHONE_26_0 +#if defined(__IPHONE_26_0) if (@available(iOS 26.0, *)) { +#if !TARGET_OS_VISION _cancelIconButton.configuration = [UIButtonConfiguration clearGlassButtonConfiguration]; +#else + _cancelIconButton.configuration = [UIButtonConfiguration filledButtonConfiguration]; +#endif } #endif [self addSubview:_cancelIconButton];