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
Changing the text color The text color of the navigation bar can be changed using two inbuilt classes: navbar-light: This class will set the color of the text to dark. This is used when using a light background color.
A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With