我的滑块电流为50.如果我向右滚动。我想要得到-0到-50。如果向右滚动我想要得到0到50.我不需要1到100.
帮助。
- (IBAction)sliderValueChanged:(UISlider *)sender {
if ([myLabel.text length] > 50){
// Make - 0 to -50
myLabel.text = [NSString stringWithFormat:@"%d", -(int)sender.value];
}else if ([myLabel.text length] < 50){
// Make 0 to 50
myLabel.text = [NSString stringWithFormat:@"%d", (int)sender.value];
}else{
myLabel.text = [NSString stringWithFormat:@"%d", (int)sender.value];
}
}
答案 0 :(得分:0)
设置滑块最小值:
slider.maximumValue = 100;
slider.minimumValue = 0;
slider.value = 50;
for Action
- (void)sliderMoved:(id)sender {
//DLog(@"slider moved");
UISlider*timeSlider = (UISlider*)sender;
if (timeSlider.value < 0) {
timeSlider.value = -50;
}
else if (timeSlider.value < 30) {
timeSlider.value = -30;
}
else if (timeSlider.value < 50) {
timeSlider.value = 0;
}
else if (timeSlider.value < 80) {
timeSlider.value = 30;
}
else if (timeSlider.value < 100) {
timeSlider.value = 50;
}
else {
timeSlider.value = 0;
}
_chosenDuration = timeSlider.value;
[_timeLabel setText:[NSString stringWithFormat: NSLocalizedString(@"time%@", nil) , _chosenDuration]];
}
设置所有条件你想要的......