I have implemented large titles in my app with the following code:
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitle
I think all of above answers don't really solve the issue and are overcomplicated. I recommend enabling/disabling large titles in each of your UIViewController
's subclasses, so they don't use large titles at the same time. Good place to do it is in the viewWillAppear
and viewWillDisappear
methods
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.largeTitleDisplayMode = .always
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.prefersLargeTitles = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.navigationBar.prefersLargeTitles = false
}