Change slider direction

后端 未结 3 1341
無奈伤痛
無奈伤痛 2021-01-25 22:26

I would to change a slider\'s direction from right to left. I want 0 to be on the right side.

For example:

My slider:

let slider = UISl         


        
3条回答
  •  生来不讨喜
    2021-01-25 23:06

    Or take the slider value with

    let realValue = slider.maximumValue - slider.minimumValue + slider.value;
    

    And set it using

    slider.value = slider.maximumValue - slider.minimumValue + realValue;
    

    Like that the slider does not need to be visually transformed, and will still respond correctly to any other input methods (keyboard, accessibility input, etc)

提交回复
热议问题