Add spacing between UIToolbar

adit picture adit · Jul 23, 2011 · Viewed 13.4k times · Source

I have a toolbar that looks like the following:

enter image description here

The issue is that it is kind of cluttered and therefore I would like to add some spacing to it. I tried doing:

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

self.toolbar_array = 
 [[NSMutableArray alloc] initWithObjects:self.mention, 
                                         spacer, 
                                         self.picture, 
                                         spacer, 
                                         share, 
                                         spacer, 
                                         self.message, nil];

But it still gives me the same thing. How can I add a 10px between these UIBarButtonItems?

Answer

Joe picture Joe · Jul 23, 2011
UIBarButtonItem *fixedSpace = 
  [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace 
                                                target:nil 
                                                action:nil];
fixedSpace.width = 10;