UIBarButtonItem title colour is showing in light gray color after enabling it

Viewed 92

I am using UIBarButtonItem and I am setting this for rightBarButtonItem and I am setting TitleTextAttributes to custom color but button color is not showing and it showing in light gray color. I am enabling and disabling the bar button when I enable it should show in custom color.

this is working fine below ios13 after ios13 it is not working, I did not change any code but I don't know why it is not working, it is not working thought the project, please find the image attached.when it is disabled on enabling, I am using Swift 4 and Xcode 10.3.

Thanks for the quick response.

my code is :

 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

    }
2 Answers

This seems to be a tint problem. Try the following solution:

self.navigationItem.rightBarButtonItem.tintColor = UIColor.clear

You can set the item color with tintColor.

   doneButton.tintColor = UIColor.red
Related