Alex Rivera | Logout

How to tint UIBarButtonItem background color?

Asked 2010-07-18T05:45:42.917
10

I have a UIToolbar that contains 2 buttons. The toolbar has a tint:

toolbar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];

How can I make the buttons have a similar tint color?

Edit
Report

1 Answer

1

UIBarButtonItems inherently respond to setTintColor, though it's not public API.

I have a custom UINavigationBar subclass that runs this block:

for (UIView *subview in self.subviews) {
    if ([subview respondsToSelector:@selector(setTintColor:)]) {
        [subview performSelector:@selector(setTintColor:) withObject:[UIColor redColor]];
    }
}

Obviously replace [UIColor redColor] with the color of your choosing.

answered 2011-08-16T23:37:09.630

Your Answer