I have an extension to configure my UINavigationController with large titles which I call in ViewDidLoad of my controller;
extension UINavigationController {
func configure(with title: String) {
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.title = title
navigationItem.largeTitleDisplayMode = .automatic
}
}
This extension doesn't seem to be called, however, when I place:
navigationController?.navigationBar.prefersLargeTitles = true
Into my ViewDidLoad, it works as expected. any ideas on why this would be?
When you call
navigationController?.navigationBar.prefersLargeTitles = trueit refers toViewController.navigationController.But your extension is for
UINavigationControllerso it refersViewController.navigationController.navigationControllerJust replace this:
With this:
and call this in
viewDidLoad: