2

In iOS 11 the UIBarButtonSystemItemFlexibleSpace bar button system item type doesn't create any spacing. I was using it to distribute space evenly between bar button items. Is this desired behavior in iOS 11 or a bug? Is there a workaround?

There aren't any notes about any changes for UIBarButtonSystemItemFlexibleSpace in iOS 11 in the current documentation. https://developer.apple.com/documentation/uikit/uibarbuttonsystemitem/uibarbuttonsystemitemflexiblespace

Here is an example that in iOS 10 will show three bar button items that are evenly spaced across the entire width of the navigation item.

UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSArray *items = @[leftButton, flex, middleButton, flex, rightButton];
[self.navigationItem setLeftBarButtonItems:items animated:YES];
Berry Blue
  • 15,330
  • 18
  • 62
  • 113
  • I'm not sure but I doubt the issue is directly related to `UIBarButtonSystemItemFlexibleSpace`. iOS 11 may have changed how it lays out buttons on a nav bar using either `leftBarButtonItems` or `rightBarButtonItems`. I bet if you set that same array of items on a toolbar it would work as expected. – rmaddy Sep 18 '17 at 23:33
  • Same issue for me. Other posts have hinted that this might be due to autolayout overriding your UIBarButton array items. – JScarry Nov 06 '17 at 18:31
  • Same issue for me. Does no-one at Apple use `UIBarButtonSystemItemFlexibleSpace`?! – hatfinch Dec 04 '17 at 22:11
  • Possible duplicate of [Negative spacer for UIBarButtonItem in navigation bar on iOS 11](https://stackoverflow.com/questions/45544961/negative-spacer-for-uibarbuttonitem-in-navigation-bar-on-ios-11) – Nike Kov Oct 03 '18 at 22:09

0 Answers0