25

I have an existing toolbar in my View... when I drag a "Bar Button Item" into the tool bar it gets slammed to left side of the toolbar (I would like it to sit on the right edge). Attempting to drag the Bar Button only results in it being "gravity snapped" back to the left side. I see nothing in the size inspector that would allow me to align it to the right edge of the toolbar. The BarButton width can be changed, but seemingly nothing else. Can anyone please give me an idea of how to move it to the right?

I will confess that I have a rookie/rudimentary understanding of (or lack thereof) Xcode/storyboarding gleaned from watching CS193p lecture videos (but I have not been able to relocate the lecture describing positioning within toolbars or pertinent documentation... a link would be welcomed.)

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Electro-Bunny
  • 1,380
  • 2
  • 12
  • 33

1 Answers1

72

Drag in a flexible space item to the left of your UIBarButton. Put another one to the right if you want it centered, and so on.

The pertinent CS193p lecture is lecture 7 (the iPad one), he covers UIToolbar at the start of that.

enter image description here

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
jrturton
  • 118,105
  • 32
  • 252
  • 268
  • @Dawgless Boyd if you feel that jrturton's answer has solved your problem, then please mark it as correct. – Mick MacCallum Mar 22 '12 at 06:41
  • 2
    Note for others who make the same mistake I did: Make sure you grab the **flexible** space bar and not the **fixed** space bar, if you want to automatically align right. – Adam Johns Jul 29 '14 at 19:02