Search code examples
iosuinavigationbaruinavigationbarappearance

How can I set the color of a custom back arrow image with UINavigationBarAppearance?


I have an iOS app that uses a custom back chevron for the back button in navigation bars with custom background colors and shadows and such. I'd like to set the color of that back indicator image to something besides the default blue. How do I do that with the new UINavigationBarAppearance APIs?

I have tried:

  • Setting the back indicator image to a template image of my shape - this works, but doesn't affect the color.
  • Setting titleTextAttributes on the normal variant of the buttonAppearance, specifying NSForegroundColorAttributeName
  • Setting titleTextAttributes on all variants of the backButtonAppearance, specifying NSForegroundColorAttributeName and NSBackgroundColorAttributeName
  • Setting tintColor on the navigation bar directly - this affects the back indicator during animation of a new navigation item, but at the end of the animation it goes back to blue.

Solution

  • The tintColor works for me. The attached screencast shows (using slow animations) that having set the tint color to black, it stays black, both pushing and popping:

    enter image description here