Search code examples
swiftnavigationuinavigationcontrolleruitabbarcontrolleruinavigationbar

How to go about creating a custom top bar/navigation bar transition for Swift?


I've inserted a link to image below as to what I am trying to create. I want a top, sticky navigation bar, that changes shape and compresses the logo contained inside of it upon scrolling down.

https://i.sstatic.net/X4q7Q.png

I am relatively new to Swift and unfamiliar with most intermediate concepts of coding out transitions. (Doesn't need to be coded out, storyboard will do if there's a way.)

Youtube tutorials gave me a bit of background as to how to work with top bars, but none can explain how I would do this in specific. I understand how to create the before and after screens, but the question is: how do I make a shape changing transition?

Maybe there are plugins, outside classes that could make this possible?

Whatever works, thanks!


Solution

  • If the content below in your provided link, is tableview or scrollview use the scrolling delegates for manipulating the above navigation view, the maths will be yours. Delegate name

    func scrollViewDidScroll(_ scrollView: UIScrollView) 
    

    here you will manipulate your navigation view accordingly.

    go through link for more help - https://medium.com/if-let-swift-programming/how-to-create-a-stretchable-tableviewheader-in-ios-ee9ed049aba3