-1

I have an Navigation bar and I want to change its left item default color to White.

enter image description here

I WANT THE BLUE TO BE WHITE

I want to done this programmatically. Currently i am using this code to change the color and title of navigation bar

- (void)viewWillAppear:(BOOL)animated
 {
  [self.navigationController setNavigationBarHidden:NO];
self.navigationItem.title = @"Advanced Settings";
UIColor *bg = [UIColor colorWithRed:79/255.0f green:166/255.0f blue:196/255.0f alpha:1.0f];

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
    // iOS 6.1 or earlier
    self.navigationController.navigationBar.tintColor = bg;
   self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};

} else {
    // iOS 7.0 or later
    self.navigationController.navigationBar.barTintColor = bg;
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
}
 }
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Sid
  • 79
  • 11
  • self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; just put the line in ViewDidLoad method. – Ashok Londhe May 18 '15 at 11:33
  • possible duplicate of [iOS 7 UIBarButton back button arrow color](http://stackoverflow.com/questions/18384488/ios-7-uibarbutton-back-button-arrow-color) – App Dev Guy May 18 '15 at 11:36
  • There are at least three questions with answers to this: 1. http://stackoverflow.com/questions/18384488/ios-7-uibarbutton-back-button-arrow-color , 2) http://stackoverflow.com/questions/7929382/ios-5-how-to-change-the-color-of-back-button-in-a-navigation-bar 3) http://stackoverflow.com/questions/19029833/ios-7-navigation-bar-text-and-arrow-color you should really consider searching before posting a question. – App Dev Guy May 18 '15 at 11:37

4 Answers4

4

Use this code in AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // set Navigation button color
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
}
Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39
2

You can add below line of code

self.navigationController.navigationBar.barTintColor = bg;//you are setting for entire navigation bar
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];//setting the buttons tint color

Hope it helps you...!

Vidhyanand
  • 5,369
  • 4
  • 26
  • 59
1

Hope following code would be helpful to you

- (void) viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
}
iPhone
  • 4,092
  • 3
  • 34
  • 58
1

Add this to your AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
}
Utsav Parikh
  • 1,216
  • 7
  • 14