iOS 7 Navigation Bar text and arrow color iOS 7 Navigation Bar text and arrow color ios ios

iOS 7 Navigation Bar text and arrow color


Behavior from some of the properties of UINavigationBar has changed from iOS 7. You can see in the image shown below :

enter image description here


Two beautiful links I'd like to share with you. For more details you can go through these links :

  1. iOS 7 UI Transition Guide.
  2. How to Update Your App for iOS 7.

Apple Documentation for barTintColor says :

This color is made translucent by default unless you set the translucent property to NO.

Sample Code :

self.navigationController.navigationBar.barTintColor = [UIColor blackColor];self.navigationController.navigationBar.tintColor = [UIColor whiteColor];[self.navigationController.navigationBar  setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];self.navigationController.navigationBar.translucent = NO;


enter image description here

This one took me about half a day to figure out but this is what worked for me.Inside the rootViewController that initializes the navigationController, I put this code inside my viewDidAppear method:

//set bar color[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:85.0/255.0 green:143.0/255.0 blue:220.0/255.0 alpha:1.0]];//optional, i don't want my bar to be translucent[self.navigationController.navigationBar setTranslucent:NO];//set title and title color[self.navigationItem setTitle:@"Title"];[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor]];//set back button color[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor,nil] forState:UIControlStateNormal];//set back button arrow color[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

My full post on this here


Swift3, ios 10

To globally assign the color, in AppDelegate didFinishLaunchingWithOptions:

let textAttributes = [NSForegroundColorAttributeName:UIColor.white]UINavigationBar.appearance().titleTextAttributes = textAttributes

Swift 4, iOS 11

let textAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]UINavigationBar.appearance().titleTextAttributes = textAttributes