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
iOS导航栏、状态栏及Tabbar高度
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- #define kIs_iphone (UI_USER_INTERFACE_IDIOM() == UIUserIn...
- 摘自:https://blog.csdn.net/hangapple/article/details/80906291
- BaseNavigationVC 1、隐藏/显示navigationBar 2、自定义导航之后,侧滑返回失...