- (BOOL)isiPhoneXSeries
{
if (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) {
return NO;
}
if (@available(iOS 11.0, *)) {
UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];
if (mainWindow.safeAreaInsets.bottom > 0.0) {
return YES;
}
}
return NO;
}
鉴于iPhone X/XS/XR/XS Max底部都会有安全距离,所以可以利用 safeAreaInsets.bottom > 0.0
来判断是否是iPhone X/XS/XR/XS Max。
safeAreaInsets
支持iOS11及以后。