Dev_P
Dev_P

Reputation: 35

change color of custom uibarbuttonitem (iOS7)

I have 5 UIBarButtonItems and will change the color of only 2. How can I do that in xcode 5?

Thanks a lot for answering!

What do I have to add to this code in AppDelegate.m ?

[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB (0x34AADC)];

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleLightContent];

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

[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

[[UIToolbar appearance] setBarTintColor:UIColorFromRGB (0x34AADC)];

Upvotes: 0

Views: 646

Answers (2)

Burhanuddin Sunelwala
Burhanuddin Sunelwala

Reputation: 5343

There is also a method as follows:

[[UIBarButtonItem appearanceWhenContainedIn:[<The class in which you want to set custom color> class], nil] setTintColor:<myColor>];

Upvotes: 1

rivtracks
rivtracks

Reputation: 43

Somewhere you created an object for these. for example:

UINavigationController *navController=[[UINavigationController alloc]init];

now you should do:

 [navController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];

Don't set the entire UINavigationController, set the object.

Upvotes: 0

Related Questions