I create one UIToolbar with code and another with interface builder. But, found out the two toolbar having different left and right padding which shown below:
From I
I stumbled upon this when trying to center a toolbar as a subview of an UIButton. As the toolbar needed to be of small width, the best solution was a flexible button on each side:
UIBarButtonItem flexibleButtonItemLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem centeredButtonItem = ...
UIBarButtonItem flexibleButtonItemRight = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIToolbar toolbar = ...
toolbar.items = @[flexibleButtonItemLeft, centeredButtonItem, flexibleButtonItemRight];