How do I reverse UISlider's min-max values?

Just subtract the value you get from the slider from the maximum value, that will reverse the values.


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);

Subclass NSSlider/UISlider. Override these two methods thus -

//Assumes minValue not necessarily 0.0

-(double)doubleValue
{

    double minVal = [self minValue];
    double maxVal = [self maxValue];

    double curValue = [super doubleValue];
    double reverseVal = maxVal - curValue + minVal;
    return reverseVal;
}

-(void)setDoubleValue:(double)aDouble
{

    double minVal = [self minValue];
    double maxVal = [self maxValue];

    double reverseVal = maxVal - aDouble + minVal;

    [super setDoubleValue:reverseVal];
}

This will invert the values allowing right/top to appear as minimum and left/bottom to appear as maximum

Tags:

Ios

Uislider