适配iphoneX 一些全局属性

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Emperor_huanzi/article/details/79912584
/// 适配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
    }
}

猜你喜欢

转载自blog.csdn.net/Emperor_huanzi/article/details/79912584