Here is how to hide Navigation Bar on Scroll in your Apple iOS App with single line of code!

Assumption: I assume your have embedded in UINavigationBar in your Apple iOS App inside Storyboard.

 
If you want to mimic Apple Safari iOS App’s behaviour of hiding navigation bar on scroll you can do it in just single line of code without any hassle.

 
You have to add following code in your View Controller’s viewDidAppear function where you have added UINavigationBar in storyboard:

 

navigationController?.hidesBarsOnSwipe = true

 
Now your viewDidAppear function will look like this:

 

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
navigationController?.hidesBarsOnSwipe = true
}

 
Hope it helps,

 
Thanks & Regards
Mandar Apte

Leave a Reply

Your email address will not be published. Required fields are marked *