Swift version: 5.2
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
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Link copied to your pasteboard.