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]
}
}