FCDeveloper
FCDeveloper

Reputation: 73

UIBarButtonItem text is very close to the right edge

The text in the UIBarButton item is close to the right edge. The button on the left seems to be fine. I did not do anything different when creating the two buttons. What is bizarre is all my UIBarButton items are working fine throughout the app, except for this one. What can I do to fix it?

Screnshot of buttons

Upvotes: 3

Views: 133

Answers (1)

matt
matt

Reputation: 535890

I'm seeing this too and I have not figured out what's causing it. I'm using the same "loose" custom nav bar in multiple places in my app, and it's just fine in most of them! Just two of the place where I'm using it produce this odd shift to the right.

It's pretty clear that it's a UIKit bug. The workaround is pretty simple: add a spacer item:

navigationItem.rightBarButtonItems = [.fixedSpace(16), saveButton]

The trouble is that some places in the app will need this extra spacer item and others will not, and only experimentation will show which is which (i.e. which ones need the workaround). But at least the problem is easily fixable!

Upvotes: 1

Related Questions