Swift version: 5.4
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.
SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.
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.