1
votes

I have a UIToolbar with 3 UIBarButtonItems and a flexible space on either side. I'm using this to navigate through an array while using the center UIBarButtonItem as a title.

The situation looks like this:

<--> [<] [Title] [>] <-->

When at the beginning of the array, I'd like to remove the [<] button and vice versa when reaching the end of the array for the [>] button.

How do I keep the [Title] button centered so that it doesn't move when one of the other UIBarButtons gets removed/added?

Notes:

  • I already know how to add/remove buttons programmatically in a toolbar

  • The problem is that every time, it centers around both remaining UIBarbuttons, where I need it to center on just the title.

1

1 Answers

1
votes

You can replace the [>] or [<] buttons with a fixed width spacer when you reach the end/beginning of the pages.