Skip to content

How to hide navigation bar when scrolling

1 min read

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

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


Share this post on:

Previous Post
Enable swipe back and the bug
Next Post
M1 mac에서 cocoapods 설치하기