What you see is a UISlider , working as apparently.
By default, at extreme values, the edge of the thumb is aligned with the edges of the track, not the center of the thumb located on the edge of the track. Thus, this is a problem if you provide an image of the thumb, the left and right edges of which are not opaque, since then the track below it becomes visible.
One partial fix is ββto redefine thumbRectForBounds(_:trackRect:value:) , so that the centers of the thumbs are located across the width of the slider. The code below shows:
class CenteredThumbSlider : UISlider { override func thumbRectForBounds(bounds: CGRect, trackRect rect: CGRect, value: Float) -> CGRect { let unadjustedThumbrect = super.thumbRectForBounds(bounds, trackRect: rect, value: value) let thumbOffsetToApplyOnEachSide:CGFloat = unadjustedThumbrect.size.width / 2.0 let minOffsetToAdd = -thumbOffsetToApplyOnEachSide let maxOffsetToAdd = thumbOffsetToApplyOnEachSide let offsetForValue = minOffsetToAdd + (maxOffsetToAdd - minOffsetToAdd) * CGFloat(value / (self.maximumValue - self.minimumValue)) var origin = unadjustedThumbrect.origin origin.x += offsetForValue return CGRect(origin: origin, size: unadjustedThumbrect.size) } }
However, I would say that this is only a partial correction, since I do not believe that this also changes the position of the thumb area, so this correction above has an unfortunate side effect, making the thumbs even less easy to touch than they are by default, so how the slider is still listening to touch the center of the slider more.
algal
source share