1、判斷 iPhone X
系列機型
static inline BOOL iPhoneXSeries() {
static BOOL iPhoneXSeries = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) {
iPhoneXSeries = NO;
}
if (@available(iOS 11.0, *)) {
UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];
if (mainWindow.safeAreaInsets.bottom > 0.0) {
iPhoneXSeries = YES;
}
}
});
return iPhoneXSeries;
}
2、添加兩張啟動圖
iPhone XR:828px x 1792px
iPhone XS Max: 1242px x 2688px
參考:https://stackoverflow.com/questions/46192280/detect-if-the-device-is-iphone-x