iPhoneX适配

iPhoneX适配

push 和 pop时,页面偏移

在有 UIScrollView 或 UIScrollView 子类(如tableView)的控制器中,push 到第二个几面和 pop 回去,scrollView 都会往下偏移。

在 AppDelegate 中用 UISCrollView 的 UIAppearance 修改

1
2
3
4
// AppDelegate 进行全局设置 不然iOS 11 push时界面会有个下滑的效果,pop回去会有个上划的效果
if (@available(iOS 11.0, *)) {
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}

TabBar 在 push 的时候会向上弹,然后还会有黑块

自定义 navigationController 重写的 push 方法里面修改 tabbar 的 frame

1
2
3
4
5
6
7
8
9
10
// 修改tabBar的frame 不然iPhone X push的时候tabBar上会向上弹
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (self.viewControllers.count > 0) {
viewController.hidesBottomBarWhenPushed = YES;
}
[super pushViewController:viewController animated:animated];
CGRect frame = self.tabBarController.tabBar.frame;
frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
self.tabBarController.tabBar.frame = frame;
}

TableView 添加 MJFooter 时,底部显示 MJFooter

修改 MJFooter 偏移位置

1
self.tableView.mj_footer.ignoredScrollViewContentInsetBottom = kSalfBottomSpace;



-------------The End-------------

本文标题:iPhoneX适配

文章作者:kysonyangs

发布时间:2018年01月20日 - 15:01

最后更新:2020年05月17日 - 16:05

原始链接:https://kysonyangs.github.io/default/iPhoneX+版本适配/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。