1. 程式人生 > >適配iphoneX 一些全域性屬性

適配iphoneX 一些全域性屬性

/// 適配IPhoneX 用到的屬性
var IS_IphoneX : Bool {
    get{
       return UIScreen.instancesRespond(to: #selector(getter: UIScreen.main.currentMode)) ? __CGSizeEqualToSize(CGSize(width: 1125, height: 2436), (UIScreen.main.currentMode?.size)!) : false
    }

}
/// 底部安全距離
var KBottomSafeHeight : CGFloat {
    get
{ if #available(iOS 11.0, *){ return (UIApplication.shared.delegate?.window??.safeAreaInsets.bottom)! }else{ return 0.0 } } } /// TabBar大小 var KTabBarHeight : CGFloat { get{ return UIApplication.shared.statusBarFrame.size.height > 20 ? 83
: 49 } } /// 導航高度 var KNavBarHeight : CGFloat { get{ return 44 + UIApplication.shared.statusBarFrame.size.height } } /// 狀態列的高度 var KStatusBarHeight: CGFloat { get{ return UIApplication.shared.statusBarFrame.size.height } }