János
János

Reputation: 35128

How to change navigation bar title color?

I tried to change title color like this, but it has no effect.

NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];

Maybe the problem that navigationbar style is black?

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

Upvotes: 1

Views: 2169

Answers (2)

Sathish Kumar VG
Sathish Kumar VG

Reputation: 2172

Try this :

self.navigationItem.title = @"The title";
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];

Upvotes: 1

Hyder
Hyder

Reputation: 1173

Use UITextAttributeTextColor instead of NSForegroundColorAttributeName for the key, and it will work :)

Upvotes: 0

Related Questions