Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 670
lewis Avatar asked Sep 07 '17 17:09

lewis


People also ask

What is Scrolledgeappearance?

The appearance settings for the navigation bar when the edge of scrollable content aligns with the edge of the navigation bar. iOS 13.0+ iPadOS 13.0+ Mac Catalyst 13.1+ tvOS 13.0+

What is navigation bar height iOS?

On iPhone tab bars remain 49 points tall in portrait and 32 points tall in landscape. iPhone X added extra height for the Home Bar to toolbars and tab bars and their sizes are unchanged from iOS 11: 83 points tall in portrait and 53 points tall in landscape.

What is a navigation controller?

NavController manages app navigation within a NavHost . Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the Navigation class rather than create a controller directly. Navigation flows and destinations are determined by the navigation graph owned by the controller.


1 Answers

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

like image 200
Claes Avatar answered Jan 13 '23 14:01

Claes