Search code examples
iosiphoneobjective-cuiappearancetintcolor

How to change navigation bar button color on iOS 7.1.1 / iPhone 5s


I want to change color of bar buttons to white.

Example:

[UINavigationBar appearance].barTintColor = [UIColor colorWithRed:251/255.0 green:108/255.0  blue:108/255.0 alpha:1.0];
[UINavigationBar appearance].tintColor = [UIColor whiteColor];
[UINavigationBar appearance].titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};

But, when run on iOS 7.1.1, the buttons is displayed with gray, NOT WHITE. This problem does not occur on the simulator.

In addition, the same problem occurs UISegmentedControl.

How to use white for tintColor?


Solution

  • I figure out it is caused by your Settings of your iPhone...

    I once freak out by this problem too...

    Check out your setting at:

    General -> Accessibility -> Increase Contrast -> Darken Colors

    Make sure you turn off Darken Colors.

    You'll find the button turned to pure white again.

    To Craig Otis:
    It is iPhone's feature, some people don't like pure white, so you don't want to force them use pure white. It is a global setting for all apps. Turning it on/off depends on users themselves.
    I just point out what is the trick.