2012-11-09 36 views
-1

可能重复:
UISlider with increments of 5如何控制UISlider在IOS

如何创建滑块和滑动值增加了10,20,30 ...... &下降了-10 ,-20,-30 ...这种格式。帮助任何其他链接的教程或源代码。感谢提前

+0

'UISlider'因为不提供'step'功能 - 您必须对其进行子类化(或向使用它的类添加委托方法)。 –

回答

0
UISlider* mySlider = [[UISlider alloc] init]; 
mySlider.minimumValue = -30.0f; 
mySlider.maximumValue = 30.0f; 

-(IBAction) sliderChanged:(id) sender{ 

     UISlider *slider = (UISlider *) sender; 
     int progressAsInt =(int)(slider.value + 0.5f); 
     NSString *newText =[[NSString alloc] 
         initWithFormat:@"%d",progressAsInt]; 
     self.sliderLabel.text = newText; 
} 
+0

OP询问有+/- 10增量/减量的滑块... –