0

I'm trying to add UIBarButtonItems to navigation bar like below. It works fine. But last button item appears very small and it doesn't set sizes automatically.

Here is how I add buttons and it worked fine before iOS 13.

var barbuttonItems:[UIBarButtonItem] = []

        for i in 0..<7 {
            let barbuttonItem = UIBarButtonItem(image: UIImage(named: "boom"), style: .done, target: self, action: #selector(barbuttonAction(_:)))
            barbuttonItem.tag = i
            barbuttonItems.append(barbuttonItem)
        }

    self.navigationItem.setLeftBarButtonItems(barbuttonItems, animated: true)

it looks like below.

enter image description here

Why is the last button too small. the image sizes that I'm using are (25, 50, 75) for 1x, 2x and 3x. I'm looking for a solution only using UIBarButtonItems.

Note: This occurs with iOS 13 update. Before that it worked fine.

Mumtaz Hussain
  • 925
  • 9
  • 23
Marlon Brando aka Ben
  • 863
  • 1
  • 14
  • 33

1 Answers1

0

Try removing your 1x image from the asset or even changing the asset to use a single scale, which would mean only having one universal image.

The problem appears to be that after the update to iOS 13 xcode thinks there is not enough room to display the larger image and so chooses the smaller version - you may even see that there isn't in fact enough room to display all of the icons at your desired size if you take out the smallest asset version and run it.

If this is the case you may need to think about making your BarButton items smaller and using the 2x asset size.

S.Mitchell
  • 91
  • 1
  • 2
  • 10