user4951
user4951

Reputation: 33090

How to change these colors on Navbar?

I have succesfully change the navbar button with this:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:26.0/255 green:132.0/255 blue:182.0/255 alpha:.5]];

What about if I want to change the color of the title (from black) or the color of the button?

enter image description here

Upvotes: 1

Views: 98

Answers (2)

karthikPrabhu Alagu
karthikPrabhu Alagu

Reputation: 3401

For navigation bar title color in iOS7 you should use the setTitleTextAttributes of UINavigationBar appearance

NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,shadow, NSShadowAttributeName, [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]];

For more navbar customization refer http://www.appcoda.com/customize-navigation-status-bar-ios-7/

Upvotes: 1

Fogmeister
Fogmeister

Reputation: 77641

This is what I have in my App Delegate in a method specially for changing appearances.

// set button tint colour to white
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

// set the bar tint colour to purplish
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:.2 green:.458823529 blue:.592156863 alpha:1.0]];

// set title text label colour to white
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

Upvotes: 2

Related Questions