m1234 m1234 - 6 months ago 3x
Swift Question

Changing one navigation bar to transparent changes all navigation bars to transparent

I have a navigation controller embedded to the first view of my app.

When I change the navigation bar to transparent on one view it changes it to transparent to all views and I cannot seem to change it back.

I would like it to be transparent for a few of my Views but not all.

To set to transparent I use:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.translucent = true


Put the code that changes the Navigation Bar's background colour in viewWillAppear, and then change the colour back to default in viewWillDisappear