What I want to get is a UISlider which lets the user not only slide when he starts on its thumbRect, but also when he taps elsewhere. When the user
This works for me in iOS 13.6 & 14.0
No need to add gesture only override beginTracking function like this :
@objc
private func sliderTapped(touch: UITouch) {
let point = touch.location(in: self)
let percentage = Float(point.x / self.bounds.width)
let delta = percentage * (self.maximumValue - self.minimumValue)
let newValue = self.minimumValue + delta
if newValue != self.value {
value = newValue
sendActions(for: .valueChanged)
}
}
override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
sliderTapped(touch: touch)
return true
}