Problem:
I have a UITableViewController
embedded in a UINavigationController
. Pressing a cell in the table view switches to another table view controller. In said table view controller, I'd like for the navigation bar to be invisible while still keeping the tab bar items so I added the following to its viewDidLoad()
:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.tintColor = .black
For the first UITableViewController, I'd like the navigation bar to be normal so in its viewDidAppear()
I did the following:
self.navigationController?.navigationBar.isTranslucent = false
Everything is working fine except during the transition (which I am doing via performSegueWithIdentifier
) the navigation bar on the first view controller disappears into blackness which looks ugly to be honest. Is there any way to prevent/fix this?
Screenshot:
You can animate the translucency of the navigation bar. So in the
viewDidLoad
for your secondUITableViewController
, you can write the following: