HamzaGhazouani / HGCircularSlider

A custom reusable circular / progress slider control for iOS application.
MIT License
2.59k stars 276 forks source link

circular slider step value #70

Open antondityativ opened 4 years ago

antondityativ commented 4 years ago

Hi! Could you tell me how can I set a step value for the circular slider? Thank you very much!

antondityativ commented 4 years ago

@HamzaGhazouani could you help me?

oddukgi commented 4 years ago

It's simple to change value. Value change adding 10

circularSlider.addTarget(self, action: #selector(updateTexts), for: .valueChanged)

@objc func updateTexts() {

     let step: CGFloat = 10
     let roundedValue = round(circularSlider.endPointValue / step) * step
     let value = roundedValue

    // same as example code 
         let ok = (circularSlider.maximumValue  / CGFloat(circularSlider.numberOfRounds))
        let ff = ceil(value / ok)

        maxValueLabel.text = String(format: "%.0f", circularSlider.maximumValue)
        minValueLabel.text = String(format: "%.0f", circularSlider.minimumValue)

        currentValueLabel.text = String(format: "%.0f", value)
        roundsLabel.text = "Round N° " +  String(format: "%.0f", ff)   
  }