ios - 启用后,UIBarButtonItem标题颜色将显示为浅灰色

标签 ios swift uinavigationbar uibarbuttonitem var

我正在使用UIBarButtonItem并将其设置为rightBarButtonItem,并将TitleTextAttributes设置为自定义颜色,但是按钮颜色未显示,并且显示为浅灰色。
我启用和禁用条形按钮时,该按钮应以自定义颜色显示。

在ios13之后,它在ios13下工作正常,但它没有工作,我没有更改任何代码,但是我不知道为什么它不工作,以为该项目不起作用,请找到附件。 when it is disabled on enabling,我正在使用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/

相关文章:

ios - 为什么我的 Swift 3.0 解码器 decodeInteger 不能用于整数?

json - alamofireobjectmapper requestObject 无法做出正确的请求和映射

ios - 状态栏下的 UIViewController 内容

android - 在 Phonegap 应用程序中存储身份验证的正确方法

ios - 将 subview 推送和弹出到堆栈时出现问题

objective-c - 尽量减少重复代码?

swift - PhysicsBody 穿过另一个 PhysicsBody,同时仍然检测碰撞

ios - 选择后不要立即取消突出显示单元格(而是在 View 将出现时取消突出显示它)

ios - 向导航栏添加阴影的问题

ios - 导航项在 iPhone 5S/5C 尺寸上不显示