🍎又发布了新手机
看来要选择新的支付方式了
废话不多说先列下最新系列屏幕尺寸和以往主流屏幕尺寸
(所列均为[[UIScreen mainScreen] bounds].size)
WX20180920-112731.png WX20180920-112736.png
XR
width 414.0f
height 896.0f
xs
width 375.0f
height 812.0f
xs max
width 414.0f
height 896.0f
x
width 375.0f
height 812.0f
8plus
width 414.0f
height 736.0f
8
width 375.0f
height 667.0f
7 plus
width 414.0f
height 736.0f
7
width 375.0f
height 667.0f
6s plus
width 414.0f
height 736.0f
6s
width 375.0f
height 667.0f
6plus
width 414.0f
height 736.0f
6
width 375.0f
height 667.0f
se
width 320.0f
height 568.0f
5s
width 320.0f
height 568.0f
顶部高度的话
WX20180920-102354.png WX20180920-102402.png
(图片网络资源 侵删)
送一些适配的宏
#define DEVICE_WIDTH [[UIScreen mainScreen] bounds].size.width
#define DEVICE_HEIGHT [[UIScreen mainScreen] bounds].size.height
//iPhone X or XS
#define iPhoneX (DEVICE_WIDTH == 375.f && DEVICE_HEIGHT == 812.f)
//iPhone XR or XS Max
#define iPhoneXR (DEVICE_WIDTH == 414.f && DEVICE_HEIGHT == 896.f)
#define iPhoneMaxScreen (DEVICE_WIDTH >= 375.f && DEVICE_HEIGHT >= 812.f)
//底部虚拟home键高度 一般用于最底部view到底部的距离
#define VirtualHomeHeight (iPhoneMaxScreen ? 34.f : 0.f)
//顶部适配的话 系统有参数可以直接获取到
#define STATUS_BAR_FRAME [[UIApplication sharedApplication] statusBarFrame]
网友评论
#define IPHONE_X \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})