I have implemented UISlider and I need to adjust track height. I found this but its not working.
self.slider.trackRect(forBounds: CGRect(x: 0, y: 0, width: 100, height: 100))
Ok...I used matt's answer + provided example and I customized the code for my needs.
let coinEnd = UIImage(/*HERE_LEFT_BLANK_IMG*/).resizableImage(withCapInsets:
UIEdgeInsetsMake(0,7,0,7), resizingMode: .stretch)
.
.
.
.
override func trackRect(forBounds bounds: CGRect) -> CGRect {
var result = super.trackRect(forBounds: bounds)
result.origin.x = 0
result.size.width = bounds.size.width
result.size.height = 10 //added height for desired effect
return result
}
override func thumbRect(forBounds bounds: CGRect, trackRect rect: CGRect, value: Float) -> CGRect {
return super.thumbRect(forBounds:
bounds, trackRect: rect, value: value)
.offsetBy(dx: 0/*Set_0_value_to_center_thumb*/, dy: 0)
}
then inherid this to my Slider and woala.
This is my desired result.
All hail matt...thank you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With