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.
Reference:
Apple Developer Documentation