? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
1、apple設(shè)備狀態(tài)欄和tabbar高度
iPhone X? 全屏狀態(tài)欄statuBar高度為44,tabBar高度為83,底部狀態(tài)增加了34.
iPhone X以下機(jī)型狀態(tài)欄statuBar高度為20,tabBar高度為49
2、下面就開(kāi)始適配了,其實(shí)也是很簡(jiǎn)單,通過(guò)宏定義去適配
//iPhone X適配
#define KStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height? ? ? ? //獲取狀態(tài)欄的高度
#define KNavBarHeight 44.0? ? ? //導(dǎo)航欄的高度
#define KTabBarHeight? ([[UIApplication sharedApplication] statusBarFrame].size.height > 20?83:49)? //根據(jù)狀態(tài)欄的高度判斷tabBar的高度
#define KtopHeitht (KStatusBarHeight + KNavBarHeight)? ? //頂部狀態(tài)欄加導(dǎo)航欄高度
#define KTabSpace? ([[UIApplication sharedApplication] statusBarFrame].size.height > 20?34:0)? ? ? //底部距安全區(qū)距離
3、UI界面的frame適配
// 當(dāng)前設(shè)備大小
#define iPhoneWidth [UIScreen mainScreen].bounds.size.width
#define iPhoneHeight [UIScreen mainScreen].bounds.size.height
//自適應(yīng)大小;這里使用的基于iphone6 的參考適配,可以修改為se/5s? {320, 568}/ 6s {375, 667}/ iphonX {375, 812}
#define kWidth(width)? ? ? ? ? ? ? ? ? ? iPhoneWidth? * width? / 375.
#define kHeight(height)? ? ? ? ? ? ? ? ? iPhoneHeight * height / 667.
#define kLevelSpace(space)? ? ? ? ? iPhoneWidth? * space? / 375.? ? ? //水平方向距離間距
#define kVertiSpace(space)? ? ? ? ? ? iPhoneHeight * space / 667.? ? ? //垂直方向距離間距
5、字體適配
#definefont(R) (R)*(kScreenWidth)/375.0//這里是iPhone 6屏幕字體#definesysFont(f) [UIFont fontWithName:@"STHeitiSC-Light" size:autoScaleW(f)]