錯誤原因:
默認情況下self.extendedLayoutIncludesOpaqueBars = NO 擴展布局不包含導(dǎo)航欄,默認情況下self.automaticallyAdjustsScrollViewInsets = YES 自動計算滾動視圖的內(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)容指示器(滾動條)的內(nèi)邊距
_tableView.scrollIndicatorInsets = _tableView.contentInset;