ios - UIBarButtonItem隐藏所需的元素和空间

标签 ios swift uibarbuttonitem

我如何隐藏UIBarButtonItem和它占用的空间?
为了隐藏我使用此代码:

searchButton.isEnabled = false
searchButton.tintColor = UIColor.clear
但是它仍然使用该空间,如果我有第三个元素,则它们之间似乎有空隙。
更改宽度不能解决我的问题。
searchButton.width = 0.0
enter image description here enter image description here

最佳答案

navigationItem.rightBarButtonItems是导航栏中右侧的可选按钮数组。您经过它并从中删除一个按钮。

关于ios - UIBarButtonItem隐藏所需的元素和空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63860550/

相关文章:

ios - 自动布局应用于 UIButton 时如何移动 UIBarButton?

ios - Ionic iOS App 错误 - 'WEB' 客户端类型不允许使用自定义方案 URI

ios - 按钮约束 Swift

iphone - 某些EKEvent与谓词不匹配

ios - Creative SDK 图像组件 - 图像编辑器 UI

swift - 使用 Swift & Stripe 解析云代码 : TypeError: Object [object Object] has no method '_each'

ios - 创建具有后退按钮样式的 UIBarButtonItem

ios - 为什么我无法在 Xcode 的连接检查器中删除 UITableViewController 的 'view' 导出?

ios - Xcode 6.0 Swift,出现错误 : can't evoke'! =' with an argument list

iphone - UINavigationBar 左侧有两个按钮