錯(cuò)誤原因:
默認(rèn)情況下self.extendedLayoutIncludesOpaqueBars = NO 擴(kuò)展布局不包含導(dǎo)航欄,默認(rèn)情況下self.automaticallyAdjustsScrollViewInsets = YES 自動(dòng)計(jì)算滾動(dòng)視圖的內(nèi)容邊距
自定義的navigationbar,隱藏掉系統(tǒng)的navigationbar,SafeAreaInsets值為(20,0,0,0)
系統(tǒng)的navigationbar,隱藏掉系統(tǒng)的navigationbar,SafeAreaInsets值為(64,0,0,0)
解決辦法:
self.extendedLayoutIncludesOpaqueBars = YES;
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
// 設(shè)置tableView的內(nèi)邊距(能夠顯示出導(dǎo)航欄和tabBar下覆蓋的內(nèi)容)
_tableView.contentInset = UIEdgeInsetsMake(64, 0, 49, 0);
// 設(shè)置內(nèi)容指示器(滾動(dòng)條)的內(nèi)邊距
_tableView.scrollIndicatorInsets = _tableView.contentInset;