我在使用 UIBarButtonItem
时遇到问题。我使用外观代理为状态 Normal
和 Disabled
设置颜色,我在 UIViewController< 的
。然而,按钮获得 viewDidLoad
方法中执行此操作Normal
颜色,即使它被禁用(并且它肯定被禁用,因为 IBAction
方法没有被调用)。
问题和这个类似text color of disabled uibarbuttonitem is always the color of the normal state ,但是,此处发布的解决方案对我不起作用。
我的应用适用于 iOS 8.2,我使用的是 Xcode 6.2
有什么想法吗?
编辑:
我不确定这是否有助于找到解决方案,但是当我使用 initWithImage:
而不是 initWithTitle:
创建我的按钮时,一切似乎都运行良好。这可能是 Apple 的错误吗?
最佳答案
swift 4
如果有人正在寻找如何快速更改 barbuttonitem 禁用状态外观。给你。
barButtonItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.lightGray], for: .disabled)
关于ios - UIBarButtonItem 已禁用,但颜色正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29165811/