I'm trying to create an effect that even though it's close to what I desire but it has some UI glitches which I'll explain.
I have, let's say, my Home navigation controller which I tap a cell that pushes a new view controller.
On that view controller's viewWillAppear(:)
I've implemented the following:
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.backgroundColor = .clear
self.navigationController?.navigationBar.tintColor = .white
self.navigationController?.navigationBar.barTintColor = .clear
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
By doing this, the pushed view controller will have its navigationBar
transparent, and still keeps the buttons visible (which is what I desire), but on the push animation, it shows a black bar on the parent controller, because it hides the parent's navigationBar
as well.
And then on the pushed view controllers viewWillDisappear(_:)
I've implemented the following:
self.navigationController?.navigationBar.shadowImage = nil
self.navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
self.navigationController?.navigationBar.isTranslucent = false
self.navigationController?.navigationBar.backgroundColor = .white
self.navigationController?.navigationBar.barTintColor = .white
By doing this, I'm trying to reset the parent's navigationBar
default properties, but by doing so I see a black bar during the animation, before it completes the animation, which causes a bad UI/UX.
Am I doing something wrong here, or there is any better approach on this?
Thank you.