IPhone 8 没刘海屏幕
示例代码:
//
// ViewController.m
// IOS_SAFEAREA_TEST
//
// Created by Hacker X on 2023/10/14.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
if (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0){
NSLog(@"使用宏检测IOS系统版本是否为IOS11及以上");
NSLog(@"__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0 => \niOS Version:%@\n,Model Name:%@\n,Model:%@",
[UIDevice currentDevice].systemVersion,
[UIDevice currentDevice].name,
[UIDevice currentDevice].model
);
}
if (@available(iOS 11.0,*)) {
NSLog(@"使用@available检测系统版本是否为IOS11及以上");
NSLog(@"@available(iOS 11.0,*) => \n iOS Version:%@\n,Model Name:%@\n,Model:%@\n",
[UIDevice currentDevice].systemVersion,
[UIDevice currentDevice].name,
[UIDevice currentDevice].model
);
//安全区域检测
//IOS 15及以上系统
if(@available(iOS 15.0,*)){
if([UIApplication sharedApplication].windows[0].safeAreaInsets.bottom>0){
NSLog(@"刘海屏-底部安全区%f",[UIApplication sharedApplication].windows[0].safeAreaInsets.bottom);
}else{
NSLog(@"没有刘海屏-底部安全区%f",[UIApplication sharedApplication].windows[0].safeAreaInsets.bottom);
}
}
else{ //IOS 15以下系统
if([UIApplication sharedApplication].windows[0].safeAreaInsets.bottom>0){
NSLog(@"底部安全区%f",[UIApplication sharedApplication].windows[0].safeAreaInsets.bottom);
}else{
NSLog(@"底部安全区%f",[UIApplication sharedApplication].windows[0].safeAreaInsets.bottom);
}
}
}
}
@end
标签:windows,currentDevice,NSLog,safeAreaInsets,UIDevice,sharedApplication,流海,留海,IOS From: https://blog.51cto.com/remotedev/8095792