Closed LoopingLouieX closed 4 years ago
Not animated, but you can do this:
var sliderValue = slider.value
slider.value[0] = 17
slider.value = sliderValue
Thanks for the answer, that's exactly what I've looked for!
Isn't it not enough to set:
slider.value[0] = 17
?
Also I wanted to ask which value type is needed here because if I'm typing in the number directly as the example above it's working.
But if I'm declare a variable first, it's not (example below).
var number = 17
slider.value[0] = number
==> Value of type 'MultiSlider?' has no subscripts
Thanks!
Yes, slider.value[0] = 17
will work fine after either setting an initial value
or a thumbCount
. Otherwise the value
array is empty.
value
is an array of CGFloat
, but in starts as empty. To avoid the error your getting, first set:
slider.value = [17]
Or alternatively:
slider.thumbCount = 1
Is there a possibility to set a value of each thumb ?
With the UISlider module you can move the thumb to a predefined value with
slider.setValue(value, animated: true)