Domanda

i've been searching with no luck. I'm trying to setup a uislider in xcode to count towards the min value while sliding right from the max value on the left.

essentially, the default value of the uislider increments from the min value on the left toward the max value when sliding right, but i want to decrement while sliding right.

is this possible using the Xcode uislider iOS developer class?

È stato utile?

Soluzione

There is no reason to change how the slider works. Put the smallest value on the left (the min) and larger value on the right (the max).

In your method that handles the slider value change, simply do:

- (IBAction)sliderChanged:(UISlider *)sender {
    CGFloat value = sender.value;
    CGFloat adjustedValue = sender.maximumValue - value + sender.minimumValue;
    // do something with the adjustedValue
}

adjustedValue will give you the max value when the slider is on the left and the min value when the slider is on the right.

Altri suggerimenti

I then needed the exact same thing as you...so rotated it another 90 degrees placing it in an upside down position. Slider is symetrical, so it looks exactly the same in both positions. But the min and max values are now the opposite.

Command is...

mySlider.transform = CGAffineTransformRotate(mySlider.transform, 180.0/180*M_PI);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top