Reputation: 1062
I am looking for UISlider value which will set the indicator at the center.
iContrastSlider.minimumValue = 85; iContrastSlider.maximumValue = 200;
So, which value I need to set,so that indicator will be always @ center. I tried with all values but it always start from 0 as shown in image.
Thanks,
Sagar
Upvotes: 0
Views: 2071
Reputation: 3330
Use the following code
float centerValue = ((iContrastSlider.maximumValue - iContrastSlider.minimumValue) / 2)+iContrastSlider.minimumValue;
[iContrastSlider setValue:centerValue animated:YES];
Upvotes: 4
Reputation: 127
add this into your slider iContrastSlider.minimumValue = 85/200; iContrastSlider.maximumValue = 200/200;
iContrastSlider.value = 115/200;
This will shows your slider value to center
Upvotes: 0
Reputation: 163238
Use simple math to calculate the average:
float centerValue = ((iContrastSlider.minimumValue + iContrastSlider.maximumValue) / 2) + iContrastSlider.minimumValue;
[iContrastSlider setValue:centerValue animated:YES];
Upvotes: 2