0

I was able to set the navigationBar for a detailedViewController to be transparent by using:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true

and this works fine. However when I link the detailedViewController to the initial firstViewController through a segue, both the parent firstViewController and the child detailedViewController have transparent navigationBar properties.

Question: how can I keep the parent firstViewController from inheriting this transparency property from the child detailedViewController?

Nii Mantse
  • 2,554
  • 2
  • 13
  • 10
  • Do you actually want the navigation bar to be transparent or do you just want it to hide? – AdamPro13 May 24 '17 at 17:33
  • if you want this property for whole app then set UINavigationBar appearance – KKRocks May 24 '17 at 17:33
  • I don't think it has anything to do with inheritance, the `firstViewController` and `detailedViewController` simply share the `navigationController` they are presented in, so changes made to it from within `detailedViewController` affect its presentation for the parent controller as well. Consider styling and re-styling the `navigationBar` using `UINavigationControllerDelegate.navigationController:willShow:` or the respective controllers' `viewWillAppear:` if you want to do it from code – crizzis May 24 '17 at 17:34
  • crizzis, I tried setting `navigationBar` transparency property under `viewWillAppear` for the `detailedViewController` however, it still affects the parent `firstViewController`. I'll give the `UINavigationControllerDelegate.navigationController:willShow:` a shot to see if this works ... – Nii Mantse May 24 '17 at 19:21
  • check this post may help https://stackoverflow.com/questions/42120482/navigation-bar-is-moving-up-to-statusbar/42909654#42909654 – Joe May 24 '17 at 20:38
  • @Joe, this post doesn't answer my question. Real issue was being able to set the `navigationBar` to be transparent - that way we can still see the title of the navigation bar and not make it hidden. Thanks for sharing this though – Nii Mantse May 29 '17 at 22:18
  • check this post https://stackoverflow.com/questions/39835420/navigationbar-delay-updating-bartintcolor-ios10/40255483#40255483 – Joe May 29 '17 at 23:03
  • @Joe, this still doesn't work for me. My test app crashes when I use `isViewLoaded` in swift 3 - – Nii Mantse May 29 '17 at 23:33

0 Answers0