iOS 11 和 iPhone X 适配

来源:互联网 发布:阿里旺旺mac版本下载 编辑:程序博客网 时间:2024/05/17 04:08

1、第一步最重要的适配,LaunchImage的适配,添加在xcassets包中的启动图,添加iPhoneX 启动图,格式为1125 × 2436
2、APPIcon 添加1024 × 1024图片,详情见Missing Marketing Icon
3、iPhone X 高度适配,判断逻辑宏

#define isIPhoneX ([UIScreen mainScreen].bounds.size.height == 812.0)

4、iPhone X 导航栏高度适配判断,iPhone X为88,这里可以动态获取导航栏高度而布局,

CGFloat y= CGRectGetMaxY(self.navigationController.navigationBar.frame); 

5、UITableView 适配

    self.estimatedRowHeight = 0;    self.estimatedSectionHeaderHeight = 0;    self.estimatedSectionFooterHeight = 0;

6、UIScrollView 适配

 if (@available(iOS 11.0, *)) {        scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;    } else {        self.automaticallyAdjustsScrollViewInsets = NO;    }

7、MJRefresh 上移问题

if (@available(iOS 11.0, *)){            tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;            tableView.contentInset = UIEdgeInsetsMake(SafeAreaTopHeight, 0, 49, 0);            tableView.scrollIndicatorInsets = tableView.contentInset;        }

目前遇到这么多,后续补充

原创粉丝点击