我在UINavigationController
中有三個viewControllers。在第二個我需要隱藏導航欄但不是後退按鈕和其他酒吧按鈕。出於這個原因,我不能使用isNavigationBarHidden = true
目前我處理上述如下:UINavigationController只隱藏navigationBar - Back動畫問題
第一的viewController:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.barTintColor = Constants.kThemeRedColor
self.navigationController?.navigationBar.tintColor = UIColor.white
self.navigationController?.navigationBar.barStyle = .black
self.navigationController?.navigationBar.isTranslucent = false
}
二的viewController(只隱藏的導航欄):
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.view.backgroundColor = UIColor.clear
}
這裏的問題是,當我從firstViewController導航到firstViewController時,在第一個viewController分別消失和出現的很短時間內,我看到一個黑色的導航欄。我知道這是因爲在第二個viewController中編寫的代碼。但我沒有任何其他解決方案。附加截圖:
第一的viewController(應該如何):
二的viewController:
第一的viewController(有黑色導航欄持續時間短):
什麼是你的免費視圖顏色?在navbar下面是tableview嗎? –