Because UILabel
is not intended to be added to UIToolBar
, I've gone down the path of creating a plain UIBarButtonItem
and doing setEnabled:NO
to prevent the "glow" effect from appearing when tapping it.
However, this grays out the title text, which is highly undesirable, so I thought it'd be nice to use a property like adjustsImageWhenDisabled:
, but upon checking the UIBarButtonItem docs... no dice.
Any other ideas on how to disable the UIBarButtonItem
without graying it out/altering its alpha?
NEW ANSWER:
This is copied from another answer (here):
For those using Interface Builder to layout your toolbar, it is also possible to do this using Interface Builder alone.
To add a label to a toolbar you need to add a generic UIView object to your Toolbar in IB by dragging a new UIView object over your UIToolbar. IB will automatically create a UIBarButtonItem that will be initialized with your custom UIView. Next add a UILabel to the UIView and edit the label graphically to match your preferred style. You can then visually set up your fixed and/or variable spacers as desired to position your label appropriately.
You must also set the background of both the UILabel and the UIView to clearColor to get the toolbar to show through correctly under the label.