iPhone X系列 的获取 - 安全区顶部和底部高度
生活随笔
收集整理的這篇文章主要介紹了
iPhone X系列 的获取 - 安全区顶部和底部高度
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
///1. 獲得當前窗口
var JY_WINDOW: UIWindow? {get{if let app = UIApplication.shared.delegate as? AppDelegate {return app.window}return nil}
}//2. iPhoneX系列
var iphoneX_Series: Bool {get {if UIDevice.current.userInterfaceIdiom != UIUserInterfaceIdiom.phone{debugPrint("不是iPhone, 是 \(UIDevice.current.userInterfaceIdiom.rawValue)")}if #available(iOS 11.0, *) {if let bottom = JY_WINDOW?.safeAreaInsets.bottom , bottom > 0 {return true}} else {debugPrint("iOS11 之前的版本")}return false}
}
安全區高度:if #available(iOS 11.0, *) {let top = JY_WINDOW?.safeAreaInsets.toplet bottom = JY_WINDOW?.safeAreaInsets.bottomlet height = UIScreen.main.bounds.size.height - top - bottom} else {let height = UIScreen.main.bounds.size.height}
轉載于:https://www.cnblogs.com/qingzZ/p/9802497.html
總結
以上是生活随笔為你收集整理的iPhone X系列 的获取 - 安全区顶部和底部高度的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 我的前端工具集
- 下一篇: 阿里云服务器新手安装nginx