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 的 frame1
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;