user3618922
user3618922

Reputation: 181

Objective - C how do I change the color of UINavigationItem

How do I change the colour of the UINavigationItem from black to white?

enter image description here

I have tried the following in my LHAppDelegate.m:

[[UINavigationBar appearance] setTintColor:UIColorFromRGB(0xFFFFFF)];


[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];

changes the whole bar to green, I am trying to change the colour of the black text 'Update Tasks'

enter image description here

Upvotes: 1

Views: 977

Answers (1)

Fahim Parkar
Fahim Parkar

Reputation: 31647

If you want to have a solid color for your navigation bar in iOS 6 similar to iOS 7 use this:

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundColor:[UIColor greenColor]];

in iOS 7 use the barTintColor like this:

navigationController.navigationBar.barTintColor = [UIColor greenColor];

or

[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];

Edit 1

To update the text color, use below.

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

Upvotes: 2

Related Questions