I need to display my app's icon in the navigation bar. To do this, I have added it as a right bar button item. I don't want it to be clickable, I just need the icon there, so I set it to disabled. The problem with this is the icon appears grey, instead of green. Is there a way to disable this button but also keep it's original color?
Try this:
let barButtonItem = UIBarButtonItem(title: "Click", style: .Done, target: self, action: #selector(didClick(_:)))
barButtonItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blueColor()], forState: .Normal)
barButtonItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blueColor()], forState: .Disabled)
barButtonItem.enabled = false
navigationItem.setRightBarButtonItem(barButtonItem, animated: false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With