SwiftRangeSlider icon indicating copy to clipboard operation
SwiftRangeSlider copied to clipboard

Is there a way to set the labels?

Open rschlack opened this issue 7 years ago • 5 comments

I would like to create 10 points on the slider stepping by 1. But I want the labels to show custom text for each of the 10 points. Is this possible?

rschlack avatar Nov 30 '17 16:11 rschlack

@rschlack were you able to do it?

saimt avatar Apr 19 '21 11:04 saimt

I was able to do that. Are you asking because you need the solution or were you offering help?

rschlack avatar Apr 19 '21 11:04 rschlack

I'm looking for a solution

saimt avatar Apr 19 '21 11:04 saimt

It's been a really long time since I looked at that project. But it looks like I just used a UILabel to show the value. My slider was a dollar amount filter.

@IBOutlet weak var priceSlider: RangeSlider!
@IBOutlet weak var priceLabel: UILabel!

@IBAction func priceSliderValueChanged(_ slider: RangeSlider) {
       self.low =  Int(slider.lowerValue)
       self.high =  Int(slider.upperValue)
        
       self.SetPriceLabel(low: self.low, high: self.high)
    }

    func SetPriceLabel(low: Int, high: Int) {
      
        
        self.priceLabel.text = "$" + low.stringWithSeparator +  " to $" + high.stringWithSeparator
        if (high == 10000) {
            self.priceLabel.text = self.priceLabel.text! + "+"
        }
    }

rschlack avatar Apr 19 '21 11:04 rschlack

Ok thank you for the help. Appreciate it!

saimt avatar Apr 19 '21 12:04 saimt