I'm using a UINvagigationController for my app, with every page setting their own title and left and right buttons.
Worked perfectly until I needed two buttons to the right. Just setting them as bar button items throws the title off-center, and the space between them is way bigger then expected:

This is how I set up those buttons to the right:
let item1 = UIBarButtonItem(customView: self.btnGoToScan)
let item2 = UIBarButtonItem(customView: self.btnExportImage)
self.navigationItem.setRightBarButtonItems([item1, item2], animated: false)
I have tried setting the width of those items, as well as adding fixed space of negative width between them - changes nothing:
let item1 = UIBarButtonItem(customView: self.btnGoToScan)
item1.width = 24
let item2 = UIBarButtonItem(customView: self.btnExportImage)
item2.width = 24
let negativeSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
negativeSpace.width = -16
self.navigationItem.setRightBarButtonItems([item1, negativeSpace, item2], animated: false)
How can I make the right bar items close and the title always centered? Like this:

Edit:
That's how the bar looks with a short title:

The title is thankfully centered for it, but the spacing around buttons on the right is way too big.
Edit 2: Tried the solution from navigation bar right bar button items spacing - did not work. Did not change the look of navigation bar in the slightest, whatever frame size I tried to set.
You can center the title by using two buttons on each side - with the 2nd button on the left being a "blank" button...
Example code: