Why do dynamic colors from my colors catalogue do not work on my navigation bar?

242 views Asked by At

I am assigning a custom color from my Colors.xcassets (that has two color values, one for light, one for dark mode) to my navigation bar using this method:

[self.navigationController.navigationBar setBarTintColor: ...;.

For some reason the navigation bar only takes the color value for the dark mode, even when the application launches in, or switches to light mode. It always uses the darker blue tint:

enter image description here

When I set this color to other objects, it works just as it should work. As I found no thread describing this problem, I am quite clueless about how I can solve this. It happens in both, iOS13 and iOS14.

Thanks in advance,

Bastian

1

There are 1 answers

3
skaak On

Create two colors, say navTint and navBack and set them as follows. Note I set them to the navigationbar as well as the toolbar.

    UINavigationController * nav          = ... whatever your nav controller may be ...;

    nav.navigationBar.tintColor           = [UIColor colorNamed:@"navTint"];
    nav.navigationBar.barTintColor        = [UIColor colorNamed:@"navBack"];
    nav.toolbar.tintColor                 = [UIColor colorNamed:@"navTint"];
    nav.toolbar.barTintColor              = [UIColor colorNamed:@"navBack"];