iOS11,iPhone X 适配笔记

iPhoneX适配

1.LaunchImage

iphoneX需要一张新的启动图:1125 × 2436 pixels,@3x,新做一张启动图

2.状态栏statusBar

iPhoneX上由于刘海部分,statusBar由20pt变成了44pt,

3.tabBar

tabBar高度发生了改变,由49pt变成49pt+34pt=83pt

// 判断是否是iPhone X
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
// 状态栏高度
#define STATUS_BAR_HEIGHT (iPhoneX ? 44.f : 20.f)
// 导航栏高度
#define NAVIGATION_BAR_HEIGHT (iPhoneX ? 88.f : 64.f)
// tabBar高度
#define TAB_BAR_HEIGHT (iPhoneX ? (49.f+34.f) : 49.f)
// home indicator
#define HOME_INDICATOR_HEIGHT (iPhoneX ? 34.f : 0.f)

iPhoneX Push 过程中TabBar位置上移
解决:在push时重置tabBar的位置

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    ....//省略代码
    [super pushViewController:viewController animated:animated];
    //重置tabBar的frame
    CGRect frame = self.tabBarController.tabBar.frame;
    frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
    self.tabBarController.tabBar.frame = frame;
}

你可能感兴趣的:(iOS11,iPhone X 适配笔记)