"Aligning UIToolbar items"

Wed 29 July 2009

//Add two UIBarButtonSystemItemFlexibleSpace items to your toolbar, to the left and right of your items

 

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

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

[toolbar setItems:[NSArray arrayWithObjects:flexibleSpaceLeft, settingsButton,deleteButton,aboutButton, flexibleSpaceRight, nil]];

[flexibleSpaceLeft release];

[flexibleSpaceRight release];

 

//Adding these as you would any other toolbar items will distribute space evenly between the two of them.