Posts How to hide navigation bar when scrolling
Post
Cancel

How to hide navigation bar when scrolling

In UINavigationController, there is a property called hidesBarsOnSwipe which hides its bars when scrolling or swipe down.

1
navigationController?.hidesBarsOnSwipe = true

We also need to set the view’s top anchor to superview’s top anchor. For example, there is a collection view inside a view controller. The collection view’s top anchor is related to Superview’s top anchor. If we don’t set it, we can’t show the navigation bar when scrolling or swipe up.

Collection view's top anchor is related to superview's top anchor.

Animated image that shows navigation bar is hidden when scrolled.

Reference:
Apple Developer Documentation

This post is licensed under CC BY 4.0 by the author.