1

I try to change the color of the navigationBar title and tried the following:

let navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.barTintColor = UIColor.red
navigationBarAppearace.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
navigationBarAppearace.tintColor = UIColor.white

Everything works fine but the color of the title is not changing. It is still black. I thought this line will change it

navigationBarAppearace.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]

Is this wrong?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Chronisch
  • 105
  • 2
  • 9

1 Answers1

1

Try this in your controller, you have to set the color once for large and normal title.

    navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.red]
    navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.red]
A. Amini
  • 521
  • 8
  • 15