Have you noticed on some apps where the navigation bar will hide when you start scrolling or if you tap? In this tutorial we will look at how we can do this. The best part about this functionality is how easy it is to implement.
Hide navigation bar on Scroll
To hide a navigation bar on scroll all we need to do is add the following line of code in the
self.navigationController?.hidesBarsOnSwipe = true
If I build and run the app that I have setup, this is what I see:
Hide navigation bar on Tap
Hiding the navigation bar on tap is just as easy as hiding when scrolling. Add the following code to your
self.navigationController?.hidesBarsOnTap = true
If I build and run the app now it will look like this:
This can be a really nice feature to include in your app depending on the type of app you are building. The best part of this is just how easy Apple has made it to add this functionality!
If you want the full source code, you can find it here.