Increment UISlider by 1 in range 1 to 100

前端 未结 7 1165
既然无缘
既然无缘 2020-12-03 18:19

I am new to iPhone,

How do I have my UISlider go from 1 to 100 in increments of 1?

    slider = [[UISlider alloc] init];
    [slider add         


        
7条回答
  •  醉梦人生
    2020-12-03 18:53

    yourSlider.minimumValue = 1;
    yourSlider.maximumValue = 100;
    [yourSlider addTarget:self action:@selector(roundValue) forControlEvents:UIControlEventValueChanged];
    
    - (void)roundValue{
        yourSlider.value = round(yourSlider.value);
    }
    

    also see this bellow answer helpful toy you,give some idea...

    UISlider increments

    and also another which may give you some idea..

    UISlider with increments of 5

提交回复
热议问题