Skip to content

Commit 94b5b21

Browse files
authored
Merge pull request #572 from TimOliver/vision-os
Add initial support for visionOS
2 parents 7bce8f0 + a970e56 commit 94b5b21

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

Objective-C/TOCropViewController/TOCropViewController.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ - (void)viewWillAppear:(BOOL)animated
143143
// so we can manually control the status bar fade out timing
144144
if (animated) {
145145
self.inTransition = YES;
146+
#if TARGET_OS_IOS
146147
[self setNeedsStatusBarAppearanceUpdate];
148+
#endif
147149
}
148150

149151
// If this controller is pushed onto a navigation stack, set flags noting the
@@ -186,7 +188,9 @@ - (void)viewDidAppear:(BOOL)animated
186188
// Now that the presentation animation will have finished, animate
187189
// the status bar fading out, and if present, the title label fading in
188190
void (^updateContentBlock)(void) = ^{
191+
#if TARGET_OS_IOS
189192
[self setNeedsStatusBarAppearanceUpdate];
193+
#endif
190194
self.titleLabel.alpha = 1.0f;
191195
};
192196

@@ -214,8 +218,10 @@ - (void)viewWillDisappear:(BOOL)animated
214218

215219
// Set the transition flag again so we can defer the status bar
216220
self.inTransition = YES;
221+
#if TARGET_OS_IOS
217222
[UIView animateWithDuration:0.5f animations:^{ [self setNeedsStatusBarAppearanceUpdate]; }];
218-
223+
#endif
224+
219225
// Restore the navigation controller to its state before we were presented
220226
if (self.navigationController && self.hidesNavigationBar) {
221227
[self.navigationController setNavigationBarHidden:self.navigationBarHidden animated:animated];
@@ -229,7 +235,9 @@ - (void)viewDidDisappear:(BOOL)animated
229235

230236
// Reset the state once the view has gone offscreen
231237
self.inTransition = NO;
238+
#if TARGET_OS_IOS
232239
[self setNeedsStatusBarAppearanceUpdate];
240+
#endif
233241
}
234242

235243
#pragma mark - Status Bar -

Objective-C/TOCropViewController/Views/TOCropOverlayView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ - (void)layoutLines
132132
}
133133

134134
//grid lines - horizontal
135-
CGFloat thickness = 1.0f / [[UIScreen mainScreen] scale];
135+
CGFloat thickness = 1.0f / self.traitCollection.displayScale;
136136
NSInteger numberOfLines = self.horizontalGridLines.count;
137137
CGFloat padding = (CGRectGetHeight(self.bounds) - (thickness*numberOfLines)) / (numberOfLines + 1);
138138
for (NSInteger i = 0; i < numberOfLines; i++) {

Objective-C/TOCropViewControllerExample/ViewController.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
7575

7676
//If profile picture, push onto the same navigation stack
7777
if (self.croppingStyle == TOCropViewCroppingStyleCircular) {
78+
#if TARGET_OS_IOS
7879
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
7980
[picker dismissViewControllerAnimated:YES completion:^{
8081
[self presentViewController:cropController animated:YES completion:nil];
8182
}];
8283
} else {
84+
#endif
8385
[picker pushViewController:cropController animated:YES];
86+
#if TARGET_OS_IOS
8487
}
88+
#endif
8589
}
8690
else { //otherwise dismiss, and then present from the main controller
8791
[picker dismissViewControllerAnimated:YES completion:^{

TOCropViewControllerExample.xcodeproj/project.pbxproj

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,10 @@
10051005
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewController;
10061006
PRODUCT_NAME = "$(TARGET_NAME)";
10071007
SKIP_INSTALL = YES;
1008+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
1009+
SUPPORTS_MACCATALYST = YES;
1010+
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES;
1011+
TARGETED_DEVICE_FAMILY = "1,2,7";
10081012
VERSIONING_SYSTEM = "apple-generic";
10091013
VERSION_INFO_PREFIX = "";
10101014
};
@@ -1042,6 +1046,10 @@
10421046
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewController;
10431047
PRODUCT_NAME = "$(TARGET_NAME)";
10441048
SKIP_INSTALL = YES;
1049+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
1050+
SUPPORTS_MACCATALYST = YES;
1051+
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES;
1052+
TARGETED_DEVICE_FAMILY = "1,2,7";
10451053
VERSIONING_SYSTEM = "apple-generic";
10461054
VERSION_INFO_PREFIX = "";
10471055
};
@@ -1067,6 +1075,9 @@
10671075
);
10681076
PRODUCT_BUNDLE_IDENTIFIER = "com.timoliver.$(PRODUCT_NAME:rfc1034identifier)";
10691077
PRODUCT_NAME = "$(TARGET_NAME)";
1078+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
1079+
SUPPORTS_MACCATALYST = YES;
1080+
TARGETED_DEVICE_FAMILY = "1,2,7";
10701081
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TOCropViewControllerExample.app/TOCropViewControllerExample";
10711082
};
10721083
name = Debug;
@@ -1087,6 +1098,9 @@
10871098
);
10881099
PRODUCT_BUNDLE_IDENTIFIER = "com.timoliver.$(PRODUCT_NAME:rfc1034identifier)";
10891100
PRODUCT_NAME = "$(TARGET_NAME)";
1101+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
1102+
SUPPORTS_MACCATALYST = YES;
1103+
TARGETED_DEVICE_FAMILY = "1,2,7";
10901104
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TOCropViewControllerExample.app/TOCropViewControllerExample";
10911105
};
10921106
name = Release;
@@ -1223,7 +1237,9 @@
12231237
);
12241238
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewControllerExample;
12251239
PRODUCT_NAME = "$(TARGET_NAME)";
1240+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
12261241
SUPPORTS_MACCATALYST = YES;
1242+
TARGETED_DEVICE_FAMILY = "1,2,7";
12271243
};
12281244
name = Debug;
12291245
};
@@ -1246,7 +1262,9 @@
12461262
);
12471263
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TOCropViewControllerExample;
12481264
PRODUCT_NAME = "$(TARGET_NAME)";
1265+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
12491266
SUPPORTS_MACCATALYST = YES;
1267+
TARGETED_DEVICE_FAMILY = "1,2,7";
12501268
};
12511269
name = Release;
12521270
};
@@ -1342,8 +1360,10 @@
13421360
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.CropViewController;
13431361
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
13441362
SKIP_INSTALL = YES;
1363+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
1364+
SUPPORTS_MACCATALYST = YES;
13451365
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
1346-
TARGETED_DEVICE_FAMILY = "1,2";
1366+
TARGETED_DEVICE_FAMILY = "1,2,7";
13471367
VERSIONING_SYSTEM = "apple-generic";
13481368
VERSION_INFO_PREFIX = "";
13491369
};
@@ -1385,8 +1405,10 @@
13851405
PRODUCT_BUNDLE_IDENTIFIER = dev.tim.CropViewController;
13861406
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
13871407
SKIP_INSTALL = YES;
1408+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
1409+
SUPPORTS_MACCATALYST = YES;
13881410
SWIFT_COMPILATION_MODE = wholemodule;
1389-
TARGETED_DEVICE_FAMILY = "1,2";
1411+
TARGETED_DEVICE_FAMILY = "1,2,7";
13901412
VERSIONING_SYSTEM = "apple-generic";
13911413
VERSION_INFO_PREFIX = "";
13921414
};
@@ -1419,7 +1441,9 @@
14191441
PRODUCT_BUNDLE_IDENTIFIER = "dev.tim.TOCropViewControllerExample.TOCropViewController-ShareExtension";
14201442
PRODUCT_NAME = "$(TARGET_NAME)";
14211443
SKIP_INSTALL = YES;
1444+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
14221445
SUPPORTS_MACCATALYST = YES;
1446+
TARGETED_DEVICE_FAMILY = "1,2,7";
14231447
};
14241448
name = Debug;
14251449
};
@@ -1446,7 +1470,9 @@
14461470
PRODUCT_BUNDLE_IDENTIFIER = "dev.tim.TOCropViewControllerExample.TOCropViewController-ShareExtension";
14471471
PRODUCT_NAME = "$(TARGET_NAME)";
14481472
SKIP_INSTALL = YES;
1473+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
14491474
SUPPORTS_MACCATALYST = YES;
1475+
TARGETED_DEVICE_FAMILY = "1,2,7";
14501476
};
14511477
name = Release;
14521478
};

0 commit comments

Comments
 (0)