給UINavigationController建立一個(gè)BaseNavigationController,然后在BaseNavigationController重寫一下以下這個(gè)方法,在你創(chuàng)建導(dǎo)航的那個(gè)地方將UINavigationController改成BaseNavigationController,只要用導(dǎo)航欄push的頁(yè)面,tabbacController都會(huì)自動(dòng)隱藏。
override func pushViewController(_ viewController:UIViewController, animated:Bool) {
if childViewControllers.count>0{
viewController.hidesBottomBarWhenPushed=true
}
super.pushViewController(viewController, animated: animated)
}