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
To make the button is faded when disable, you can set alpha for it. There are two options for you:
First way: If you want to apply for all your buttons in your app, so you can write extension for UIButton like this:
extension UIButton {
open override var isEnabled: Bool{
didSet {
alpha = isEnabled ? 1.0 : 0.5
}
}
}
Second way: If you just want to apply for some buttons in your app, so you can write a custom class from UIButton like below and use this class for which you want to apply:
class MyButton: UIButton {
override var isEnabled: Bool {
didSet {
alpha = isEnabled ? 1.0 : 0.5
}
}
}