UIToolbar and Flexable/Fixed bar button items

2019-07-08 09:58发布

问题:

I have a toolbar, where I want to have one UIBarButtonItem centered and have another on the very right. However when I add the button on the right, my centered button gets shifted further to the left (see attached). I can't figure out how to get this resolved without using code (I would like to use interface builder only). Any ideas?

回答1:

To do this in just IB, add a fixed bar button item to the very left of the bar that's the exact same width of the 'switch camera' button, followed by a flexible button, your camera icon, another flexible space, and the switch camera.

So it would look like:

|--fixed space--||--flexible space--||Camera Button||--flexible space--||switch camera|