错误原因:
默认情况下self.extendedLayoutIncludesOpaqueBars = NO 扩展布局不包含导航栏,默认情况下self.automaticallyAdjustsScrollViewInsets = YES 自动计算滚动视图的内容边距
自定义的navigationbar,隐藏掉系统的navigationbar,SafeAreaInsets值为(20,0,0,0)
系统的navigationbar,隐藏掉系统的navigationbar,SafeAreaInsets值为(64,0,0,0)
解决办法:
self.extendedLayoutIncludesOpaqueBars = YES;
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
// 设置tableView的内边距(能够显示出导航栏和tabBar下覆盖的内容)
_tableView.contentInset = UIEdgeInsetsMake(64, 0, 49, 0);
// 设置内容指示器(滚动条)的内边距
_tableView.scrollIndicatorInsets = _tableView.contentInset;
网友评论