I am unable to change the color of UIBarItem programmatically swift. I want to change the color of this "create" button whether something happens. But nothing changes the color of the button.
Here is an image of the button :
I am unable to change the color of UIBarItem programmatically swift. I want to change the color of this "create" button whether something happens. But nothing changes the color of the button.
Here is an image of the button :
here is how You can achieve it programatically in viewDidLoad
add this
override func viewDidLoad() {
super.viewDidLoad()
let butt = createButton.customView as? UIButton
butt?.setTitleColor(.green, for: .normal)
// Do any additional setup after loading the view.
}
Please try tintColor attribute
let rightBarButtonItem = UIBarButtonItem(title: "Text", style: .plain, target: self, action: #selector(objcAction))
rightBarButtonItem.tintColor = UIColor.red
navigationItem.rightBarButtonItem = rightBarButtonItem