1

I am working on a project and want to hide the navigation bar in my App. I have already found some code in the web to hide the bar, but always when I hide it, the swipe back function disables. So I don't want to have the navigation bar, but I want to have the swipe back function.

I have already tried this code:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    navigationController?.setNavigationBarHidden(false, animated: animated)
}

And this code here too:

self.navigationController?.navigationBar.isHidden = true

And so on...

Fabian Müller
  • 318
  • 2
  • 11

1 Answers1

1

when you hide nav bar swipe to go back won't work. Maybe you want totally transparent nav bar which I suggest to you, because you can constraint views with safe area like that and you will have swipe to go back.

    let navBarAppearance = UINavigationBarAppearance()
    navBarAppearance.configureWithTransparentBackground()
    navigationController?.navigationBar.standardAppearance = navBarAppearance
    navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
    navigationController?.navigationBar.compactAppearance = navBarAppearance
    self.navigationController?.navigationBar.prefersLargeTitles = false
    self.navigationController?.navigationBar.topItem?.title? = "Back"
MMDev11070
  • 131
  • 5