iPhone屏幕尺寸和开发适配

image.png

iOS真机适配:

// 屏幕宽度
public static let Screen_Width: CGFloat = UIScreen.main.bounds.width
// 屏幕高度
public static let Screen_Height: CGFloat = UIScreen.main.bounds.height
// 是否iPhoneX系列
public static let Is_iPhoneX: Bool = {
        if UIScreen.main.bounds.height == 812.0 || UIScreen.main.bounds.height == 896.0  || UIScreen.main.bounds.height == 844.0 || UIScreen.main.bounds.height == 926.0 {
            return true
        } else {
            return false
        }
    }()

// 状态栏高度(算上顶部安全距离)
public static let Statusbar_Height: CGFloat = {
        if #available(iOS 13.0, *) {
            return UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame.size.height ?? (BFDefine.Is_iPhoneX ? 48.0 : 20.0)
        } else {
            return UIApplication.shared.statusBarFrame.size.height
        }
    }()
// 顶部安全距离
public static let Top_Height: CGFloat = Statusbar_Height - 20
// 底部安全距离
public static let Bottom_Height: CGFloat = BFDefine.Is_iPhoneX ? 34 : 0
// 导航栏高度(算上顶部安全距离和状态栏高度)
public static let Navbar_Height: CGFloat = Statusbar_Height + 44
    
// tab栏高度(算上底部安全距离)
public static let Tabbar_Height: CGFloat = BFDefine.Is_iPhoneX ? 83 : 49
    
// 主窗口
public static var Key_Window: UIWindow {
        get {
            UIApplication.shared.keyWindow ?? UIApplication.shared.windows[0]
        }
    }

版权声明:
作者:Mr李
链接:https://www.techfm.club/p/48163.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>