In Swift, UIControl
doesn't seem to have a setEnabled:
method. Is there a way to detect when the control state was changed?
Override UIButton's setEnabled method in Swift
You can do something like that in your subclass:
override var enabled:Bool {
didSet {
//Your code
}
}
Swift 3.0
override var isEnabled:Bool {
didSet {
//Your code
}
}
Thanks! Completely forgot that we can override properties in Swift –
Clementia
I was wondering if we could ovveride properties in swift the moment I fell on this!!! –
Timmons
Just a note that you do not need to call super here - Swift does that automatically when overriding properties. –
Maddiemadding
In swift 3 it is now:
override var isEnabled: Bool {
didSet {
//Your code
}
}
© 2022 - 2024 — McMap. All rights reserved.