Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift xcode hide navigation bar for specific view

Tags:

ios

swift

I want to hide the navigation bar for a specific view, and add my own custom "back button"

The way I am doing this now is by:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    self.navigationController?.navigationBarHidden = true
    }

It works but it takes 0.2 sec before the bar gets hidden, so you kinda can see it jump up once the view loads. Is there any other way to hide it?

like image 418
Kiwo Tew Avatar asked Jul 20 '15 01:07

Kiwo Tew


People also ask

How do I hide the navigation bar in Swift?

How To Hide Navigation Bar In Swift. To hide the navigation bar in Swift, you'll need to add code to two methods: viewWillAppear and viewWillDisappear . That's it to hide the navigation bar in your view controller.

How do I hide the navigation bar?

If you want to view files or use apps in full screen, double-tap the Show and hide button to hide the navigation bar. To show the navigation bar again, drag upwards from the bottom of the screen.


2 Answers

I was facing the same issue, this was fixed using the following method:

self.navigationController?.setNavigationBarHidden(true, animated: true)
like image 87
J Curti Avatar answered Oct 22 '22 05:10

J Curti


Do it in the viewDidLoad for that view because the viewDidAppear runs once the view is shown to the user. You could also try setting the alpha of the navbar to 0 for faster action.

like image 27
Aryaman Goel Avatar answered Oct 22 '22 04:10

Aryaman Goel