Is it possible to have a red UIBarButtonItem?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
If anyone is looking for code to exactly duplicate a simple UIBarButtonItem:
And delete.png is:
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.
If using IB (Interface Builder), drag a
UIView
from the Library onto theUIToolBar
, and it will generate aUIBarButtonItem
with a custom view. You can then add any other controls you want to it, e.g.UIButton
,UILabel
,UIActivityIndicatorView
.When you have UIBarButtonItem setup in a Storyboard, you have to set the tintColor in the
viewWillAppear()
orviewDidAppear()
method (putting it in viewDidLoad() doesn't work for me...):Or in Swift:
Note: tested on iOS 8/9.
Using a custom image doesn't work as it just uses the alpha to render the button.
You can set the tintColor property of a UIBarButtonItem in iOS 5. If you need to support iOS 4, check out this blog post. It details using a UISegmentedControl styled to look like a single button.