Get your own Facebook style navigation bar with HMScrollNavigationBar

March 16, 2017

Have you ever seen a navigation bar in your Facebook app? Maybe you’ve wondered how to do it? Now, with our simple library, you can have the same feature in your own app!

Example

ScrollGif

How it work ?

It’s really quite simple - our navigationBarAnimator is a property in the UIViewController. This is a object of HMNavigationBarAnimator type which implements UIScrollViewDelegate protocol.

When you run a setup function providing your UIScrollView element and UIView (your custom view which will be your navigation bar) as parameters, a navigationBarManager starts acting as a delegate of UIScrollView. When scroll is detected, we start calculation of the height at which your navigation bar and UIScrollView should now be and then, if needed, we start an animate function from UIView.

The navigation bar hides immediately when you scroll down and shows with delay when you scroll up, just like a Facebook navigation bar.

The code has been written in Swift 3.0.

Here is a link to our repo (https://github.com/HandcraftedMobile/HMScrollNavigationBar)

Posted by: Piotr Sękara, https://github.com/piotr-sekara