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
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
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];
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:
UIStatusBarStyleLightContent
NO
NO
You can use the following:
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]];
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.
Just replace with NSForegroundColorAttributeName
with UITextAttributeTextColor
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};