I have a label that is controlled for a UISlider. When I get half way with the slider it shows .50. How can I change that .50 to 50%? Thanks so much!
My slider code:
- (IBAction) sliderValueChanged:(UISlider *)sender {
tipPercentLabel.text = [NSString stringWithFormat:@" %.2f", [sender value]];
}
UISlider is a fraction between 0.0 and 1.0.
So how about something like:
tipPercentLabel.text = [NSString stringWithFormat:@" %f%%", ([sender value] * 100)];
The "%%
" in the format string indicates a percent character to be printed. I might be a tiny bit off in the format string (maybe cast the multiplied value to an integer and use "%d%%
").