Wouter Scholtens
Wouter Scholtens

Reputation: 147

How to keep a UIBarButtonItem centered when adding/removing other UIBarbuttons?

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:

Upvotes: 1

Views: 311

Answers (1)

WhoaItsAFactorial
WhoaItsAFactorial

Reputation: 3558

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

Upvotes: 1

Related Questions