我正在使用UIBarButtonItem并将其设置为rightBarButtonItem,并将TitleTextAttributes设置为自定义颜色,但是按钮颜色未显示,并且显示为浅灰色。
我启用和禁用条形按钮时,该按钮应以自定义颜色显示。
在ios13之后,它在ios13下工作正常,但它没有工作,我没有更改任何代码,但是我不知道为什么它不工作,以为该项目不起作用,请找到附件。 ,我正在使用Swift 4和Xcode 10.3。
感谢您及时的回复。
我的代码是:
var doneButton: UIBarButtonItem!
doneButton = UIBarButtonItem.init(title: "Select", style: .plain, target: self, action: #selector(doneButtonAction))
doneButton.setTitleTextAttributes([.foregroundColor: Colors.red], for: .normal)
self.navigationItem.rightBarButtonItem = doneButton
doneButton.isEnabled = false
if selctedTagArray.count == 0 {
//it barbutton color should change to red
self.doneButton.isEnabled = true
}
最佳答案
这似乎是一个色彩问题。请尝试以下解决方案:
self.navigationItem.rightBarButtonItem.tintColor = UIColor.clear
关于ios - 启用后,UIBarButtonItem标题颜色将显示为浅灰色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60566533/