UINavigationController a simple property that masks some complex behavior. If you set
hidesBarsOnSwipe to be true for any
UINavigationController, then iOS automatically adds a tap gesture recognizer to your view to handle hiding (and showing) the navigation bar as needed. This means you can mimic Safari's navigation bar behavior in just one line of code, like this:
navigationController?.hidesBarsOnSwipe = true
Remember to set this back to
false when you want to stop the behavior from happening.
Available from iOS 8.0
Did this solution work for you? Please pass it on!
Other people are reading…
About the Swift Knowledge Base
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Master iOS 11 now!
My book Practical iOS 11 gives you seven complete coding projects that teach all the major new features in iOS 11 in a smart, practical way.