In Swift, UIControl
doesn't seem to have a setEnabled:
method. Is there a way to detect when the control state was changed?
Classes in Swift can call and access methods, properties, and subscripts belonging to their superclass and can provide their own overriding versions of those methods, properties, and subscripts to refine or modify their behavior.
A computed property can also be overridden in a class by adding override to the property in the extending class.
We use the override keyword to declare method overriding. For example, class Vehicle { func displayInfo(){ ... } } class Car: Vehicle { // override method override func displayInfo() { ... } }
Swift version: 5.6. The override is used when you want to write your own method to replace an existing one in a parent class. It's used commonly when you're working with UIViewControllers , because view controllers already come with lots of methods like viewDidLoad() and viewWillAppear() .
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With