0

I configure my navigationBar like this in the AppDelegate:

func setupNavBar() {
    let barAppearance = UINavigationBar.appearance()
    barAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: appRed]
    barAppearance.setBackgroundImage(UIImage(color: .white), for: UIBarMetrics.default)
    barAppearance.shadowImage = UIImage()
}

This works fine, however when I set the title as follows:

navigationController.navigationItem.title = "Hello"

this never works and I do not see any title. This is regardless of where I place the above line (viewDidLoad, viewDidAppear etc.)

Alk
  • 5,215
  • 8
  • 47
  • 116

1 Answers1

2

Try to set the view controller's title property to "Hello"

self.title = "Hello"

If it works, you can find an explanation in AWebster's answer here Swift - Title Not Appearing for Navigation View Controller

Savca Marin
  • 427
  • 4
  • 11