Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the Range of a UISlider Programmatically

How is it possible to set the min max ranges of the UISlider programmatically?

For example (dummy code)

UISlider* slider = [[UISlider alloc] init];
slider.min = -3;
slider.max = 3;

EDIT:

So I have the following:

sl.minimumValue = 5;
NSLog(@"MIN VAL: %d", sl.minimumValue);

This doesn't work, I still get it logging the value 0. Is this because I have set values in interface builder?

like image 702
user559142 Avatar asked Dec 16 '22 10:12

user559142


2 Answers

Here is it.

UISlider* slider = [[UISlider alloc] init];
slider.minimumValue = -3.0f;
slider.maximumValue = 3.0f;
like image 156
sherilyn Avatar answered Dec 19 '22 00:12

sherilyn


In the case updating selected values of IBOutlet-ed RangeSeekSlider

rangeSeekSlider.selectedMinValue = 10.0
rangeSeekSlider.selectedMaxValue = 100.0
rangeSeekSlider.setNeedsLayout()
like image 38
ak_ninan Avatar answered Dec 18 '22 23:12

ak_ninan