iPhone 全机型分辨率和尺寸大全

机型
(iPhone)
尺寸
(inch)
像素密度
(ppi)
缩放因子
(Scale Factor)
纵横比
(Aspect ratio)
逻辑分辨率
(pt)
渲染分辨率
(px)
屏幕(物理)分辨率
(px)
竖屏安全区域
(safeAreaInsets)
2G/3G/3GS3.51651.03 : 2320 x 480320 x 480320 x 480top: 20
bottom: 0
4/4s3.53302.016 : 9320 x 480640 x 960640 x 960top: 20
bottom: 0
5/5c/5s/SE4.03262.016 : 9320 x 568640 x 1136640 x 1136top: 20
bottom: 0
6/6s/7/8/SE2/SE34.73262.016 : 9375 x 667750 x 1134750 x 1134top: 20
bottom: 0
6P/6s Plus/7P/8P5.54013.016 : 9414 x 7361242 x 22081242 x 2208top: 20
bottom: 0
X/Xs/11 Pro5.84583.019 : 9375 x 8121125 x 24361125 x 2436top: 44
bottom: 34
Xr/11/6.13262.019 : 9414 x 896828 x 1792828 x 1792top: 48
bottom: 34
Xs Max/11 Pro Max6.54583.019 : 9414 x 8961242 x 26881242 x 2688top: 48
bottom: 34
12 mini/13 mini5.44763.019 : 9375 x 8121125 x 24361080 x 2340top: 50
bottom: 34
12/12 Pro/13/13 Pro/146.1460319 : 9390 x 8441170 x 25321170 x 2532top: 47
bottom: 34
12 Pro Max/13 Pro Max/14 Plus6.74583.019 : 9428 x 9261248 x 27781248 x 2778top: 47
bottom: 34
14 Pro6.14603.019 : 9393 x 8521179 x 25561179 x 2556top: 54
bottom: 34
14 Pro Max6.74603.019 : 9430 x 9321290 x 27961290 x 2796top: 59
bottom: 34

通常导航栏与tabbar的高度是固定的:

  • 导航栏高度:44.0
  • tabbar高度:49.0
    参考文献:

手机屏幕尺寸大全

安全区域偏移量

随着iPhone X 刘海屏机型增多,屏幕尺寸也发生改变,安全距离也不同。竖屏状态下顶部安全距离有20、44、47、48、50、54、59等(今后可能还有其他数值),底部安全距离有0、34(今后可能有其他数值);横竖屏切换时安全距离也不相同:横屏时左右的安全距离相同,由原来竖屏下底部安全距离34改为与顶部安全距离相同。即横屏时左右安全距离相同,都为竖屏下的顶部安全距离。
适配方案:考虑安全区域偏移量,对应处理

// MARK: - 安全区域(不考虑存在导航栏与tabbar的安全区域,因为是取的是window)
public extension UIScreen {/// 获取根 windowstatic var lp_window: UIWindow? {if let window = UIApplication.shared.delegate?.window {return window}else{if #available(iOS 11, *) {return UIApplication.shared.keyWindow}else if #available(iOS 13.0, *) {let scene = UIApplication.shared.connectedScenes.firstlet windowScene = scene as? UIWindowScenereturn windowScene?.windows.first}else{return UIApplication.shared.windows.filter {$0.isKeyWindow}.first}}}/// main 即将被弃用,故新增APIstatic var lp_main: UIScreen {if #available(iOS 16.0, *) {return lp_window!.screen}else{return UIScreen.main}}///状态栏高度static var lp_statusBarHeight: CGFloat {if #available(iOS 13.0, *) {return lp_window?.windowScene?.statusBarManager?.statusBarFrame.size.height ?? 0.0} else {return UIApplication.shared.statusBarFrame.size.height}}/// navBar 高度(不考虑安全区域)static var lp_navBarHeight: CGFloat {return 44.0}/// navBar + 底部安全距离 navBar 安全区域高度static var lp_safeAreaNavBarHeight: CGFloat {return lp_navBarHeight + lp_statusBarHeight}/// tabbar 高度(不考虑安全区域)static var lp_tabBarHeight: CGFloat {if let tabController = UIScreen.lp_window?.rootViewController as? UITabBarController {return tabController.tabBar.safeAreaLayoutGuide.layoutFrame.height}return 49.0}/// tabbar + 底部安全距离 tabbar 安全区域高度static var lp_safeAreaTabBarHeight: CGFloat {if let tabController = UIScreen.lp_window?.rootViewController as? UITabBarController {return tabController.tabBar.frame.height}return lp_tabBarHeight + lp_safeAreaBottom}///安全区域范围static var lp_safeAreaLayoutFrame: CGRect {return lp_window?.safeAreaLayoutGuide.layoutFrame ?? .zero}///安全距离的Insetsstatic var lp_safeAreaInsets: UIEdgeInsets {return lp_window?.safeAreaInsets ?? .zero}///顶部安全距离static var lp_safeAreaTop: CGFloat {return lp_safeAreaInsets.top}///左边安全距离static var lp_safeAreaLeft: CGFloat {return  lp_safeAreaInsets.bottom}///底部安全距离static var lp_safeAreaBottom: CGFloat {return  lp_safeAreaInsets.bottom}///右边安全距离static var lp_safeAreaRight: CGFloat {return  lp_safeAreaInsets.right}///屏幕是否是全面屏(带圆角、刘海的屏幕)static var isFullScreen: Bool {return lp_safeAreaBottom > 0 ? true : false}
}// MARK: - 屏幕宽高
public extension UIScreen {static var lp_screenSize: CGSize {return lp_main.bounds.size}///屏幕宽static var lp_screenWidth: CGFloat {return lp_screenSize.width}///屏幕高static var lp_screenHeight: CGFloat {return lp_screenSize.height}
}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部