In Swift, UIControl
doesn't seem to have a setEnabled:
method. Is there a way to detect when the control state was changed?
Asked
Active
Viewed 7,052 times
2 Answers
36
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
}
}

Mohamed Jaleel Nazir
- 5,776
- 3
- 34
- 48

bzz
- 5,556
- 24
- 26
-
Thanks! Completely forgot that we can override properties in Swift – Andrey Gordeev Jan 27 '15 at 13:59
-
I was wondering if we could ovveride properties in swift the moment I fell on this!!! – Nicolas Manzini Jan 09 '16 at 16:31
-
4Just a note that you do not need to call super here - Swift does that automatically when overriding properties. – Josh Sklar Sep 23 '16 at 21:08