Swift version: 5.1
iOS 11 introduced a new design for navigation bar titles, allowing developers to enable large titles for view controllers that needed to be particularly prominent.
By default these large titles are disabled, but you can enable them with one line of code in your navigation controller’s top view controller:
navigationController?.navigationBar.prefersLargeTitles = true
That will enable large titles for all view controllers that subsequently get pushed, but you can be more selective by adjusting the
navigationItem.largeTitleDisplayMode property of your view controllers.
For example, if you wanted subsequent view controllers to never use large titles, you would put this into their
navigationItem.largeTitleDisplayMode = .never
SAVE 20% ON iOS CONF SG The largest iOS conference in Southeast Asia is back in Singapore for the 5th time in January 2020, now with two days of workshops plus two days of talks on SwiftUI, Combine, GraphQL, and more! Save a massive 20% on your tickets by clicking on this link.
Available from iOS 11.0 – see Hacking with Swift tutorial 1
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.