Log139 Log139 - 1 year ago 155
Objective-C Question

uibarbuttonitem highlight tint/color

can we change the color/tint of a uibarbuttonitem when it is selected and it highlights? The app i am creating will be be used out doors often and would like it to be more noticeable in high glare situations for the user to know that he actually pressed the button.

EDIT: i would like to change the color for the button's highlighted state


I haven't tried this, but you could try subclassing UIBarButtonItem and then overriding the touchesEnded:withEvent: and touchesBegan:withEvent: methods and then using them to set the tintColor for your UIBarButtonItem instance.

You'd add this to your UIBarButtonItem subclass:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    self.tintColor = [UIColor redColor];

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    self.tintColor = [UIColor blueColor];