user1244311
user1244311

Reputation: 301

How to align a UIBarButtonItem on toolBar?

I have added a tool bar and I am adding a button to that toolbar. That button is automatically aligned to left irrespective to the frame that i set to that button. I want that button to be center of the tool bar. How to make that?

Upvotes: 0

Views: 1324

Answers (2)

John Smith
John Smith

Reputation: 2022

along with the button, add a flexible space item on the right and on the left sides of the button

Upvotes: 0

DrummerB
DrummerB

Reputation: 40201

Add a flexible space to your tabbar to the left (and right) of your button.

UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                            target:nil action:nil];

Upvotes: 2

Related Questions