Search code examples
cocoa-touchuinavigationcontrolleruikituinavigationbarios11

iOS Navigation Bar Prefers Large Titles Scroll Behaviour


In iOS 11 the system apps all compress the navigation bar as you scroll down if you enable prefersLargeTitles:

enter image description here

I can't figure out how to implement this in my own apps though, the bar stays the same by default:

enter image description here

The only thing I can see is Hide Bars On Swipe, but that hides the whole bar rather than compressing it:

enter image description here

This is just an empty project created in Xcode 9 beta and with a new storyboard added.

What do I need to do to get the same behaviour as the system apps?


Solution

  • Don't set anything regarding Large Titles in Interface Builder / Storyboard, only in code. That worked for me.

    So in the navigation bar in storyboards, Prefers Large Titles unchecked.

    In your view controller:

    self.navigationController?.navigationBar.prefersLargeTitles = true