How can we get the range between two thumbs in UISlider
. My application contains price range selection i didn't get with a single thumb. Here i need to show the range on labels above the thumbs also these labels are inside the images.
We cannot give two thumbs for one slider because we cannot change UI But we can give With our own design. For that first we have to take two buttons and two UIViews We need to change the buttons positions according to user touch and also change UI widths based on buttons positions. We have have a third party frame works like NMRangeSlider
and VPRangeSlider
.
I've created a filter without pods just for curious with next API:
let slider = DoubledSlider()
slider.minimumValue = 0
slider.maximumValue = 100
To fetch UIEvent.valueChanged
simply do this:
slider.addTarget(self, action: #selector(self.didChangeSliderValue), for: .valueChanged)
And finally handle values like below:
@objc private func didChangeSliderValue() {
print(self.slider.values.minimum)
print(self.slider.values.maximum)
}
And this looks like
You can customize API, UI or whatever. All code source is open. Enjoy.
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