20

I'm having problems changing the text and status bar text colour to white.

I want all the black text to be white,any ideas?

I have seen a lot of solutions but none seem to work on iOS 7

6 Answers 6

55

My solution was to add the following to AppDelegate:

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

Swift 3:

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

Swift 5:

UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]

In iOS 13 you can set the appearance on a navigation bar itself using UINavigationBarAppearance:

let appearance = UINavigationBarAppearance()
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]

navigationBar.standardAppearance = appearance
29

To turn your title text color white put this in your viewDidLoad

self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeTextColor : [UIColor whiteColor]}

To change your Status bars text color to white add this to your view

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
4
  • 2
    Great the first part worked but i had to change it to: self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; but the second part is not working. Am i adding to the AppDelegate.m? Commented Sep 19, 2013 at 21:34
  • You should add that to your viewControllers didLoad or willAppear method. You may also need to call [self setNeedsStatusBarAppearanceUpdate]. You could also change the status bar's appearance app wide in your info.plist
    – Rich86man
    Commented Sep 20, 2013 at 1:17
  • I have added it to my MasterViewController.m viewDidLoad but the status bar text is still black. Commented Sep 21, 2013 at 17:31
  • You must have ViewControllerBasedStatusBarApperance set to yes (this is the default). If that is the case you will need to override - (UIStatusBarStyle)preferredStatusBarStyle in each of your viewControllers. Make sure you return UIStatusBarStyleLightContent if you're looking for white text in your status bar
    – Rich86man
    Commented Sep 21, 2013 at 18:37
12

There are a couple of things you might want to do.

1) To change the color of the title:

self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};

2) To change the color of Bar buttons:

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

3) To make the status bar text color white through the whole app:

On you project plist file:

  • Status bar style: UIStatusBarStyleLightContent
  • View controller-based status bar appearance: NO
  • Status bar is initially hidden: NO
5

You can use the following:

[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]];
3

This is what i did..

Do the following to make the status bar text color white through the whole app.

On you project plist file:

Status bar style: UIStatusBarStyleLightContent

View controller-based status bar appearance: NO

Status bar is initially hidden: NO

No need to implement preferredStatusBarStyle or call setNeedsStatusBarAppearanceUpdate if you want the same behavior throughout the app.

3
  • This is what I needed to do to upgrade a project that was built in xcode 4.6.3. It seems that the defaults don't update to what they usually are for new xcode 5 projects and this fixed it.
    – johnrechd
    Commented Sep 24, 2013 at 18:31
  • meta.stackexchange.com/questions/78658/…
    – Lucas
    Commented Nov 6, 2013 at 19:40
  • this won't help with navigation bar title text color
    – vaddieg
    Commented Dec 5, 2013 at 11:26
3

Just replace with NSForegroundColorAttributeName with UITextAttributeTextColor

 self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.