這是iOS 12.1的一個bug夹界,癥狀見下圖:
image
默認的UITabBar的isTranslucent(磨砂)為true馆里,并且push viewController 時 設(shè)置hidesBottomBarWhenPushed = true,就會出現(xiàn)此問題可柿。
將磨砂屬性設(shè)置為false即可解決此問題:
tabBar.isTranslucent = false
但同時要注意鸠踪,這樣做之后,tabBar上面的這個tableView的底部依賴要做修正复斥,不需要再減去tabBar的height了营密。比如,現(xiàn)在要這么寫:
// 這里用了SnapKit庫
tableView.snp.makeConstraints { (constraintMaker) in
if #available(iOS 12.1, *) {
// iOS 12.1, tabBar的isTranslucent設(shè)為false
constraintMaker.bottom.equalToSuperview()
} else {
// iOS 12.1之前的版本目锭,tabBar的isTranslucent仍設(shè)為true评汰,所以要減去tabBarHeight
constraintMaker.bottom.equalToSuperview().offset(0 - tabBarHeight)
}
}
究其原因纷捞,可以查看參考鏈接2。原因是從其它頁面返回時被去,tabBar 內(nèi)的按鈕 UITabBarButton 被設(shè)置了錯誤的 frame主儡,frame.size 變?yōu)?(0, 0) 導致的。
參考: