IOS(刘海/留海/流海)屏幕判断

IPhone 8 没刘海屏幕

示例代码:

objectivec 复制代码
//
//  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
相关推荐
catchadmin1 天前
NativePHP v4 让 Blade 构建原生 iOS 与 Android 界面
android·ios·ai·php
weixin_403810131 天前
iOS免越狱自动化三种方式对比:代理模式、蓝牙HID与OTG HID怎么选
ios·自动化·跨境电商·ios脚本·苹果群控·苹果投屏·苹果脚本
_瑞1 天前
APM_函数调用栈展开
ios·编译原理
极客猴子2 天前
会议记录带日历功能的iOS录音软件推荐:按日期查找会议内容
ios
2501_915918412 天前
Rust 程序抓包解密,rustls 不认系统证书的几种办法
开发语言·后端·网络协议·ios·adb·https·rust
MaoJiu2 天前
「Landmark-Driven Beauty Rendering:实时磨皮与腮红的算法与 GPU 实现」
ios
冯汉栩2 天前
Swift Control RollingCountdownView(动画倒计时)
开发语言·ios·swift
_瑞3 天前
读懂 iOS 的线程调用栈
ios·编译原理·汇编语言
末代iOS程序员华仔3 天前
iOS 语聊直播/聊天APP4.3条例被拒解决
flutter·ios·swift
2601_965798474 天前
Build a Fast, High-Ranking Restaurant Website with Rolanda Theme
开发语言·ios·swift