1. 判断是否是iPhone X
#define IS_IPHONE_X ([[UIScreen mainScreen] bounds].size.height == 812.0)
判断是否是iOS 11
#define IOS11 (DeviceSystemVersionBigThan(11.0)||DeviceSystemVersionEqualTo(11.0))
2. UITableView上方出现空白问题解决方案
if (IOS11) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
3. UITableView高度不对问题,setContentOffset:和scrollRectToVisible:失效问题
self.tableView.estimatedRowHeight = 0;
4. UINavigationItem的titleView不居中问题
iOS11titleView的实现有变化,需要找到titleView的superView,然后将superView的x设置为0即可
5. 界面与safe area重叠问题(iPhone X)
下面是苹果文档,大概意思就是要避免在iPhone X屏幕最下方放置可交互的控件
Avoid explicitly placing interactive controls at the very bottom of the screen and in corners.People use swipe gestures at the bottom edge of the display to access the Home screen and app switcher, and these gestures may cancel custom gestures you implement in this area. The far corners of the screen can be difficult areas for people to reach comfortably.
解决方案就是减去相应的高度
if (IS_IPHONE_X) {
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, height-24) style:UITableViewStylePlain];
} else {
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth,height) style:UITableViewStylePlain];
}
6. iPhone X上UITabBarController的tabBar高度问题
iPhone X上的UITabBar默认高度为83,所以使用的时候应注意
网友评论