I am setting the tintColor
of a UIBarButtonItem
. This works as long as the color is a bright color, as soon as I try to set it to darkGrayColor
nothing happens, in fact it changes the tint to white! But if I change the color to redColor
then it works... What is going on here?
UIBarButtonItem *penButton = [_toolBar.items objectAtIndex:3];
UIBarButtonItem *crossButton = [_toolBar.items objectAtIndex:4];
//This actually sets the tint to white not gray, which is odd?
[penButton setTintColor:[UIColor darkGrayColor]];
[crossButton setTintColor:[UIColor redColor]]; //Red is fine, as is green etc
The difference between [UIColor redColor]
and [UIColor darkGrayColor]
is that the former is set using RGB values and the latter with a grayscale, and the UIBarButtonItem
is somehow ignoring the grayscale. You can test this theory by comparing:
[penButton setTintColor:[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]];
[penButton setTintColor:[UIColor colorWithWhite:0.5 alpha:1.0]];
If the former is as expected but the latter is not, then the problem is indeed with grayscale. Otherwise I have no idea what's causing this behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With