depicus

changing the digital world one bit at a time...

Blants (noun) the rants of a blogger

  1. Adding a UILabel to a UIToolbar the easy way…

    May 6, 2011 by The Man

    I simply quote…

    “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.”

    Genius and simple. Thanks to Matt R and Stackoverflow