Reputation: 11
I can change tintcolor every button by
UIToolbar* tb = [[self navigationController] toolbar];
for (UIBarButtonItem * item in tb.items)
item.tintColor = [UIColor yellowColor];
But can not change tintcolor all buttons by [[[self navigationController] toolbar] setTintColor:[UIColor yellowColor]] ;
What's wrong?
Upvotes: 0
Views: 177
Reputation: 77651
The easiest way to do this is with the UIAppearance
protocol.
Somewhere in your app (I do this in the app delegate) put something glide this...
[[UITabBar appearance] setBarTintColor:[UIColor colorWithWhite:0.97 alpha:1]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor yellowColor]];
EDIT
Just saw that you're using UIToolBar
not Tab Bar. So you can do this...
[[UIBarButtonItem appearanceWhenContainedIn:[UIToolBar class] set.....
You can mess around with other properties too like...
// this uses an embedded font to set the font of tab items.
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont bariolRegularFontOfSize:14]} forState:UIControlStateNormal];
You can do the same sort of thing with labels, buttons, navigation bars, etc...
Upvotes: 1