Storyboard UIButton extension for willSet of isEnabled doesn't get called

Viewed 344

I am trying to make a UIButton extension that prints something when setting the isEnabled value. But it doesn't seem to be triggered. (Doesn't print):

extension UIButton {
    override open var isEnabled: Bool {
        willSet {
            print("About to set isEnabled to \(newValue)")
            // print isn't triggered when I set isEnabled later
        }
    }
}

But it works when I use the extension on a custom subclass of UIButton:

class CustomUIButton: UIButton {}

extension CustomUIButton {
    override open var isEnabled: Bool {
        willSet {
            print("About to set isEnabled to \(newValue)")
            // print is triggered when I set isEnabled later
        }
    }
}

The UIButtons are added in the storyboard when it doesn't work but if they are added in code then it works as expected. Why is this? And how can I make it work on UIButtons added in storyboard?

0 Answers
Related