2012-11-09 79 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增量/減量的滑塊... –