Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give two thumbs for UISlider

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.

like image 328
saikumar Lakshmi Pallagani Avatar asked Mar 23 '17 09:03

saikumar Lakshmi Pallagani


2 Answers

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.

like image 184
lokesh Avatar answered Oct 19 '22 18:10

lokesh


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

enter image description here

You can customize API, UI or whatever. All code source is open. Enjoy.

like image 3
shokuroff Avatar answered Oct 19 '22 18:10

shokuroff