I'm trying to implement a custom class extending UIControl in swift and can't quite work out the initialisation.
class UIRangeSlider: UIControl {
var minimumValue: Float32
var maximumValue: Float32
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
init(frame: CGRect, minimumValue: Float32, maximumValue: Float32) {
self.minimumValue = minimumValue
self.maximumValue = maximumValue
super.init(frame: frame)
}
}
When I try to create an instance of this class with:
var sliderFrame = CGRect(x: 20, y: 200, width: 200, height: 5)
var slider = UIRangeSlider(frame: sliderFrame, minimumValue: 1, maximumValue: 10)
I get the error:
Property 'self.minimumValue' not initialised at super.init call
What is the correct way to write this custom initialiser?