Search code examples
iosuinavigationcontrolleruinavigationbarios7tintcolor

Changing the color of the UINavigationController buttons


I have this in my UINavigationController:

(void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view.

    self.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationBar.barTintColor = [UIColor blackColor];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor greenColor];
    //self.navigationItem.rightBarButtonItem.tintColor = [UIColor greenColor];
    //self.navigationItem.rightBarButtonItem = nextButton;
}

The first two lines work fine: the text of the navigation bar is white and the background is black. The third (and fourth when I tried), just seem to be ignored.

How do I make the text color of the left and right bar buttons be different colors? I see Apple's apps in ios7 doing this.


Solution

  • I am not sure but if you want to apply the different colors to left and right bar buttons then just try to apply the tintColor independently and remove the line that sets the tintColor to navigationBar. Just try it.

    Update :

    It looks like Apple don't want us to apply the different color on left and right bar buttons anymore. Behavior from some of the properties of UINavigationBar has changed from iOS 7. I have already given description in my Answer, you can check it.