Reputation: 49
So on my HomeViewController
I added a custom Navigation Bar @IBOutlet weak var navBar: UIView!
and I'm adding it to the navigation bar as:
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.backgroundColor = .clear
self.navigationController?.view.insertSubview(navBar, belowSubview: navigationController!.view)
self.navigationController?.navigationBar.isTranslucent = false
self.edgesForExtendedLayout = []
Now when I push MenuViewController
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "MenuVC") as! MenuViewController
self.navigationController?.pushViewController(vc, animated: true)
This custom navBar
is still on the top. I want the default navigation bar to show again as I only want custom navBar
on HomeViewController
Upvotes: 0
Views: 1214
Reputation: 1680
navbar
into the navigationController.view
,
that's why it will be seen on every viewController
where navigationController
is or will be used.You can do following to solve this
navbar
into subview of current UIView
self.view.addSubview(navbar)
navigationBar
from that particular UIViewController
self.navigationController?.setNavigationBarHidden(true, animated: false)
ViewController
self.navigationController?.setNavigationBarHidden(false, animated: false)
Upvotes: 1
Reputation: 2566
Either you should remove the customView from your navigationController
before pushing your MenuViewController
or access the customview using its tag from MenuViewController
's viewWillAppear
and remove it from superview or hide it
Upvotes: 1