Is it possible to have a red UIBarButtonItem?
A:
You can create a custom image for the button and use that. Else, if you have set the tintColor of your navbar or toolbar to red, the button items on these will also appear red.
lostInTransit
2009-03-20 06:29:23
+2
A:
Using a custom image doesn't work as it just uses the alpha to render the button.
leftspin
2009-06-03 05:39:09
+9
A:
You can create custom UIButton with your desired look and initialize your UIBarButtonItem with it as a custom view.
UIButton *button = [UIButton buttonWithType:....];
...(customize your button)...
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:button];
Marcus Foster
2009-06-03 12:06:33
+2
A:
see http://www.iphonedevsdk.com/forum/iphone-sdk-development/33286-color-image-uibarbuttonitem-uitoolbar.html which helped me...
Steve
2010-01-27 22:00:05
Good link - the big post in there has the good info. I was trying to create a UIBarButtonItem with a UIImageView as the customView. The better way to do it, as described in that post, is to create a UIButton for the customView instead. In my case I also needed to change the image based on the state of the data (whether the data was a favorite item or not) so I also set an image for the button's "UIControlStateSelected" state, then toggled it as needed:[(UIButton *)self.favBarButtonItem.customView setSelected:isFavorited];Sure wish the SDK made this more straightforward!
Jason
2010-02-11 16:07:18
A:
If using IB (Interface Builder), drag a UIView
from the Library onto the UIToolBar
, and it will generate a UIBarButtonItem
with a custom view. You can then add any other controls you want to it, e.g. UIButton
, UILabel
, UIActivityIndicatorView
.
apalopohapa
2010-09-29 18:50:49