gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 12:05:33 24 4
gpt4 key购买 nike

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

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

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

它为 2 个按钮留出空间,但只有第一个出现,第二个实际上没有出现。

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

enter image description here enter image description here

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)

最佳答案

将顺序更改为[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."

关于ios - 导航栏填充的 UIBarButtonSystemItem.FixedSpace 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35163287/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com