UIBarButtonSystemItem.FixedSpace 导航栏填充不起作用

UIBarButtonSystemItem.FixedSpace for nav bar padding not working

我正在尝试将完成按钮添加到我的导航栏(直接构建 UINavigationBar 而不是使用控制器)。完成按钮看起来很好,操作有效,但导航栏边缘没有填充。

我尝试添加第二个带有固定 space 的条形按钮项目,但没有效果。

对我来说更奇怪的是,当我尝试添加按钮两次时 [rightButton,rightButton]

它为 2 个按钮制作了 space,但只有第一个出现,第二个实际上没有出现。

感谢您的帮助,我附上了一些代码和照片以供参考。

let rightButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "doneAction:")

let rightButtonPadding = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
            rightButtonPadding.width = 50

            let items = UINavigationItem()
            items.title = name.uppercaseString
            items.rightBarButtonItems = [rightButton,rightButtonPadding]
            items.hidesBackButton = true

            navBar.pushNavigationItem(items, animated: false)

试着玩 UIBarButtonItemStyleDone/UIBarButtonItemStylePlain。另请检查此线程:iOS7 excessive navigationbar button padding

将顺序更改为 [rightButtonPadding ,rightButton]

来自文档:

"Items are displayed right-to-left in the same order as they appear in the array. Thus, the first item in the array is the rightmost item and other items are added to the left of the previous item."