OK, it's better.
What is the problem, precisely ? What do you get ? What did you expect ? Please show screenshots.
Here are my screenshots showing it is working, but thumb can move out of slider, which is probably not expected:
You can force the thumb inside slider by making the following change:
override func thumbRect(forBounds bounds: CGRect, trackRect rect: CGRect, value: Float) -> CGRect {
let thumbDiameter = CGFloat(defaultDiameter * value)
let origin = CGPoint(x: (currentLocation?.x ?? bounds.width / 2) - thumbDiameter / 2, y: 0 /*(currentLocation?.y ?? thumbDiameter / 2) - thumbDiameter / 2*/) // <<-- CHANGED
return CGRect(origin: origin, size: CGSize(width: thumbDiameter, height: thumbDiameter))
}