objective-ciphoneipaduibarbuttonitemtoolbaritems

Add spacing between UIToolbar


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?


Solution

  • UIBarButtonItem *fixedSpace = 
      [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace 
                                                    target:nil 
                                                    action:nil];
    fixedSpace.width = 10;