Rajesab Yadahalli
Rajesab Yadahalli

Reputation: 1

How to hide NavigationBar from sub view?

I am facing an issue of NavigationBar, I dont want it in subview (child view), I also used setNavigationBarHidden() method to hide but it is not working.

class VehicleSavingPopupViewController: UIViewController {
@IBOutlet weak var bottomView: UIView!
@IBOutlet weak var backGroundView: UIView!
override func viewDidLoad() {
    super.viewDidLoad()
    animateView()
    backGroundView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(backGroundViewTapped(_:))))
    
    // Do any additional setup after loading the view.
}
override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    navigationController?.setNavigationBarHidden(true, animated: false)
}

private func animateView(){
    UIView.animate(withDuration: 0.5, delay: 0, options: [.transitionCurlDown],
                   animations: { [weak self] in
                    guard let self = `self` else {return}
                    self.bottomView.center.y -= self.bottomView.bounds.height
    }, completion: nil)
}

Upvotes: 0

Views: 67

Answers (1)

Gábor Hertelendy
Gábor Hertelendy

Reputation: 179

I set this in my own navigationController class but it should work in your viewDidLoad() method as well.

navigationController?.navigationBar.isHidden = true

Upvotes: 0

Related Questions