Reputation: 3909
Here's what is being set and it's close to the color I need:
NSDictionary *barButtonItemTitleAttributesEnabled = @{
NSFontAttributeName:[UIFont MRFontLightOfSize:17],
NSForegroundColorAttributeName:[UIColor whiteColor]
};
NSDictionary *barButtonItemTitleAttributesDisabled = @{
NSFontAttributeName:[UIFont MRFontLightOfSize:17],
NSForegroundColorAttributeName:[UIColor colorWithWhite:1.0f alpha:0.25f]
};
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemTitleAttributesEnabled forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemTitleAttributesDisabled forState:UIControlStateDisabled];
But I'd prefer to somehow set the disabled text color to the same color as the selected state, is there a way to do that with the appearance proxy calls?
Also tried this:
NSDictionary *barButtonItemDisabled = [[UIBarButtonItem appearance] titleTextAttributesForState:UIControlStateSelected];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemTitleAttributesEnabled forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemDisabled forState:UIControlStateDisabled];
Upvotes: 0
Views: 3489
Reputation: 2031
If you want to give different colours for different items then you should use
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
initWithTitle:@"Done" style:UIBarButtonItemStylePlain
target:self action:@selector(done)];
[doneButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
Otherwise you should just simply write
[toolBar setTintColor:[UIColor whiteColor]];
Upvotes: 1
Reputation: 3909
resolved by removing TextTitleAttribute code above and setting the toolBar tintColor appearance proxy:
[[UIToolbar appearance] setTintColor:[UIColor whiteColor]];
this made it so that just enabling or disabling the buttons set them to the right color.
Upvotes: 4