Having a UISLider with min value 5 and max value 10 how can I show the value range with 0.5 interval in uilabel
_ie.text = [NSString stringWithFormat:@"%0.1f",(_Iel.value)];
Having a UISLider with min value 5 and max value 10 how can I show the value range with 0.5 interval in uilabel
_ie.text = [NSString stringWithFormat:@"%0.1f",(_Iel.value)];
You can round like this:
_ie.text = [NSString stringWithFormat:@"%0.1f",(roundf(_Iel.value * 2.0) * 0.5)];
This will work for 0.5 or any other interval
- (IBAction)sliderValueChanged:(id)sender
{
self.increment = 0.5f;
float roundedSliderValue = roundf(self.theSlider.value / self.increment) * self.increment;
_ie.text = [NSString stringWithFormat:@"%0.1f",roundedSliderValue];
}