In my iPhone app, I have a UIButton which I have created in Interface Builder. I can successfully enable and disable it like this in my code ...
sendButton.e
Set title color for different states:
@IBOutlet weak var loginButton: UIButton! {
didSet {
loginButton.setTitleColor(UIColor.init(white: 1, alpha: 0.3), for: .disabled)
loginButton.setTitleColor(UIColor.init(white: 1, alpha: 1), for: .normal)
}
}
Usage: (text color will get change automatically)
loginButton.isEnabled = false