Skip to content

Commit 79dbd74

Browse files
committed
Updated toolbar layout for visionOS
1 parent 107ce5f commit 79dbd74

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

Objective-C/TOCropViewController/TOCropViewController.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ - (CGRect)frameForToolbarWithVerticalLayout:(BOOL)verticalLayout
286286
CGRect frame = CGRectZero;
287287
if (!verticalLayout) { // In landscape laying out toolbar to the left
288288
if (@available(iOS 26.0, *)) {
289+
#if !TARGET_OS_VISION
289290
CGFloat minPadding = 8.0f;
291+
#else
292+
CGFloat minPadding = 16.0f;
293+
#endif
290294
frame.origin.x = insets.left + minPadding;
291295
frame.origin.y = minPadding;
292296
frame.size.width = kTOCropViewControllerToolbarHeight;
@@ -314,13 +318,17 @@ - (CGRect)frameForToolbarWithVerticalLayout:(BOOL)verticalLayout
314318
insets.bottom = 8.0f;
315319
}
316320

321+
#if !TARGET_OS_VISION
317322
const char* components[] = {"Radius", "Corner", "display", "_"};
318323
NSString *selectorName = @"";
319324
for (NSInteger i = 3; i >= 0; i--) {
320325
selectorName = [selectorName stringByAppendingString:[NSString stringWithCString:components[i]
321326
encoding:NSUTF8StringEncoding]];
322327
}
323328
const CGFloat cornerRadius = [[UIScreen.mainScreen valueForKey:selectorName] floatValue];
329+
#else
330+
const CGFloat cornerRadius = 64.0f;
331+
#endif
324332
frame.size.width = CGRectGetWidth(self.view.bounds) - MAX(cornerRadius, insets.bottom * 2.0f);
325333
} else {
326334
frame.size.width = CGRectGetWidth(self.view.bounds);

Objective-C/TOCropViewController/Views/TOCropToolbar.m

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ - (void)setup {
6060
UIView *containerView = self;
6161
#ifdef __IPHONE_26_0
6262
if (@available(iOS 26.0, *)) {
63+
UIVisualEffect *effect = nil;
64+
#if !TARGET_OS_VISION
6365
UIGlassEffect *glassEffect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleClear];
6466
glassEffect.interactive = YES;
65-
_glassView = [[UIVisualEffectView alloc] initWithEffect:glassEffect];
67+
effect = glassEffect;
68+
#else
69+
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleProminent];
70+
effect = blurEffect;
71+
#endif
72+
_glassView = [[UIVisualEffectView alloc] initWithEffect:effect];
6673
_glassView.cornerConfiguration = [UICornerConfiguration capsuleConfiguration];
6774
_glassView.userInteractionEnabled = YES;
6875
[self addSubview:_glassView];
@@ -108,10 +115,14 @@ - (void)setup {
108115
[_doneIconButton setImage:[TOCropToolbar doneImage] forState:UIControlStateNormal];
109116
[_doneIconButton setTintColor:[UIColor colorWithRed:1.0f green:0.8f blue:0.0f alpha:1.0f]];
110117
[_doneIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
111-
#ifdef __IPHONE_26_0
118+
#if defined(__IPHONE_26_0)
112119
if (@available(iOS 26.0, *)) {
120+
#if !TARGET_OS_VISION
113121
UIButtonConfiguration *configuration = [UIButtonConfiguration prominentGlassButtonConfiguration];
114122
configuration.baseForegroundColor = [UIColor blackColor];
123+
#else
124+
UIButtonConfiguration *configuration = [UIButtonConfiguration filledButtonConfiguration];
125+
#endif
115126
_doneIconButton.configuration = configuration;
116127
}
117128
#endif
@@ -139,9 +150,13 @@ - (void)setup {
139150
_cancelIconButton = [UIButton buttonWithType:UIButtonTypeSystem];
140151
[_cancelIconButton setImage:[TOCropToolbar cancelImage] forState:UIControlStateNormal];
141152
[_cancelIconButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
142-
#ifdef __IPHONE_26_0
153+
#if defined(__IPHONE_26_0)
143154
if (@available(iOS 26.0, *)) {
155+
#if !TARGET_OS_VISION
144156
_cancelIconButton.configuration = [UIButtonConfiguration clearGlassButtonConfiguration];
157+
#else
158+
_cancelIconButton.configuration = [UIButtonConfiguration filledButtonConfiguration];
159+
#endif
145160
}
146161
#endif
147162
[self addSubview:_cancelIconButton];

0 commit comments

Comments
 (0)