I have a UINavigationItem
on my view controller, and I am trying to reduce the spacing between my two RightBarButtonItems
. Here is some of my code:
// Create two UIBarButtonItems
let item1:UIBarButtonItem = UIBarButtonItem(customView: view1)
let item2:UIBarButtonItem = UIBarButtonItem(customView: view2)
var fixedSpace:UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
fixedSpace.width = -20.0
// Add the rightBarButtonItems on the navigation bar
viewController.navigationItem.rightBarButtonItems = [item2, fixedSpace, item1]
As can be seen, I am using a FixedSpace UIBarButtonItem
, but this is not changing the spacing for some reason. I have thought about subclassing either the UINavigationItem
or the UIBarButtonItem
so that I can set the spacing accordingly, but I couldn't seem to find any methods that I could override to change the spacing between items.
Any insight on how to solve this problem would be greatly appreciated!