iPhone系列手机适配

2019-02-22  本文已影响0人  caiyajie

屏幕尺寸参数

手机系列 逻辑分辨率 物理分辨率 缩放比例 尺寸
iPhone4,4s 320x480 640x960 @2x 3.5
iPhone5,5s,5c,SE 320x568 640x1136 @2x 4
iPhone6,6s,7,8 375x667 750x1334 @2x 4.7
iPhone6p,6sp,7p,8p 414x736 1080x1920 @3x 5.5
iPhoneX,Xs 375X812 1125x2436 @3x 5.8
iPhoneXr 414x896 828x1792 @2x 6.1
iPhoneXsMax 414x896 1242x2688 @3x 6.5

系列样图

2962939-da970a64a4f7baeb.png 20141226184058420.png

判断机型

//判断是否是ipad
#define isPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
//判断iPhone4系列
#define is_iPhone4_All ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPhone5系列
#define is_iPhone5_All ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPhone6系列
#define is_iPhone6_All  ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iphone6+系列
#define is_iPhone6P_All ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPhoneX,iPhoneXs
#define IS_IPHONE_X_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPHoneXr
#define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPhoneXs Max
#define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断是否为 iPhoneXS Max,iPhoneXS,iPhoneXR,iPhoneX
#define IS_IPhoneX_All ([UIScreen mainScreen].bounds.size.height == 812 || [UIScreen mainScreen].bounds.size.height == 896)

StatusBar,NavigationBar,TabBar

//状态栏、导航栏、标签栏高度
#define Height_StatusBar (IS_IPhoneX_All ? 44 : 20)

#define Height_NavBar 44.0f

#define Height_TopBar (Height_StatusBar + Height_NavBar)

#define Height_TabBar (IS_IPhoneX_All ? 83.0f:49.0f)

#define Height_BottomSafe (IS_IPhoneX_All? 34.0f:0.0f)

iPhoneX系列适配

上一篇下一篇

猜你喜欢

热点阅读