Not able to change navigationbar text color or tint color in Objective C

365 views Asked by At

I want to set both navigation bar backgound color and navigation tint color so that I can set tint color of all system buttons present in the navigation bar. I have written the following code:

NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[ver objectAtIndex:0] intValue] >= 7) {
    // iOS 7.0 or later
    self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];
    self.navigationController.navigationBar.translucent = NO;
}else {
    // iOS 6.1 or earlier
    self.navigationController.navigationBar.tintColor = [UIColor orangeColor];
}
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setBarTintColor:[UIColor orangeColor]];

This code only changes the background color of the navigation bar but not the tint color of buttons. Buttons are showing in default blue color. But while navigating to other screens some times buttons color gets changed to the color I set by the code above but this does not happens always.

1

There are 1 answers

1
tekgy On BEST ANSWER

This will surely work , call it in Appdelegate

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];