If you want to clip the top part of the thumbImage, you should use:
public func thumbRectForBounds(bounds: CGRect, trackRect rect: CGRect, value: Float) -> CGRect
So add this to your code:
durationSlider.thumbRectForBounds(...)
And set the CGRect
of the thumbRect
to have the value of durationSlider.frame.origin.y
as its own origin.y
.
Here’s another temporary solution, I’ll get back to the thumbRectForBounds
method shortly:
let mask = CAGradientLayer(layer: durationSlider.layer)
let lineTop = (durationSlider.bounds.height/2 - 0.5) / durationSlider.bounds.height
mask.frame = durationSlider.bounds
mask.colors = [UIColor.clearColor().CGColor, UIColor.blackColor().CGColor]
mask.locations = [lineTop, lineTop]
durationSlider.layer.mask = mask
0
solved set UIslider thumb image in swift