Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separator between toolbar items in UIToolbar

How to add a separator between buttons in a UIToolbar?

Sample image is shown in the below link

enter image description here

like image 797
user930514 Avatar asked Feb 07 '12 17:02

user930514


2 Answers

I did it with a custom view button, with a 1 pixel wide background:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 44)];
label.backgroundColor = [UIColor whiteColor];

UIBarButtonItem *divider = [[UIBarButtonItem alloc] initWithCustomView:label];
// Add button to array of toolbar items
[items addObject:divider];
// Or set items directly:
//toolbar.items = [NSArray arrayWithObject:divider];
label.text = @"";
like image 111
NoelHunter Avatar answered Oct 24 '22 12:10

NoelHunter


I can think of two ways :

(a) You could make them very thin toolbar buttons with user interaction disabled.

(b) Your other choice would be to implement your own toolbar. I'd try (a) first ;)

like image 45
deanWombourne Avatar answered Oct 24 '22 11:10

deanWombourne