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:
isTranslucent: A Boolean value indicating whether the navigation bar is translucent (true) or not (false). isOpaque: A Boolean value indicating whether the title is empty and an opaque bezel is set.
Change the Bar Style A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.
The appearance settings for the navigation bar when the edge of scrollable content aligns with the edge of the navigation bar. iOS 13.0+ iPadOS 13.0+ Mac Catalyst 13.1+ tvOS 13.0+
I had a very similar problem recently. Try setting self.navigationController?.navigationBar.translucent = true
in both view controllers and self.edgesForExtendedLayout = UIRectEdgeNone
.
Storyboard version: Extended Edges - Under Top Bars
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With