let KScreenSize = UIScreen.main.bounds
let KScreenWidth:CGFloat = UIScreen.main.bounds.size.width
let KScreenHeight:CGFloat = UIScreen.main.bounds.size.height
let K_Is_iPhoneX = isIPhoneX()
private
func isIPhoneX() -> Bool{
if #available(iOS 11, *) {
guard let w = UIApplication.shared.delegate?.window, let unwrapedWindow = w else {
return false
}
if unwrapedWindow.safeAreaInsets.left > 0 || unwrapedWindow.safeAreaInsets.bottom > 0 {
return true
}
}
return false
}
///状态栏的高度
private
func getStatusBarHight() -> CGFloat {
var statusBarHeight:CGFloat = 0
if #available(iOS 13.0, *) {
let statusBarManager = UIApplication.shared.windows.first?.windowScene?.statusBarManager
statusBarHeight = statusBarManager?.statusBarFrame.size.height ?? 0
}else{
statusBarHeight = UIApplication.shared.statusBarFrame.size.height
}
return statusBarHeight
}
///底部安全距离
private
func getTabbarSafeBottomMargin() -> CGFloat {
var safeBottom:CGFloat = 0
if #available(iOS 11, *) {
let safeArea = UIApplication.shared.keyWindow?.safeAreaInsets
safeBottom = safeArea?.bottom ?? 0
}
return safeBottom
}
///导航栏高度
let kNavBarHeight:CGFloat = 44.0
///状态栏高度
let KStatusBarHeight:CGFloat = getStatusBarHight()
//状态栏和导航栏总高度
let kNavBarAndStatusBarHeight:CGFloat = kNavBarHeight + KStatusBarHeight
///底部安全距离
let KTabbarSafeBottomMargin:CGFloat = getTabbarSafeBottomMargin()
let kTabBarHeight:CGFloat = 49 + KTabbarSafeBottomMargin
网友评论