(IOS)UISlider增量/减量为固定值(假如为5)

- (void)setupSlider

{

    UISlider*slider = [[UISlideralloc]init];

    [self.view addSubview:slider];

    [slideraddTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];

    slider.maximumValue=100;

    slider.minimumValue=0;

    slider.frame=CGRectMake(200,20,100,30);

}

- (void)sliderAction:(UISlider*)slider

{

    [slidersetValue:((int)((slider.value+2.5) /5) *5)animated:NO];

}

你可能感兴趣的:((IOS)UISlider增量/减量为固定值(假如为5))