Using UIProgressBar to show percentage?

142 views Asked by At

I was hoping there was a way to utilise the UIProgressBar by having it show the percentage or something instead of it animating/loading.

For example, if in a game you have collected 25/100 coins, the progress bar would be lit 25% of the way...

I haven't been able to find anything on this, so maybe you can't. But I've tried this with no luck:

-(void)ProgressMade{
    progress.progress = 25; 
}

Then I realised progress is (float) so tried this:

-(void)ProgressMade{
    progress.progress = 25/1000; //0.0 - 0.1
}

But still nothing :(

The only difference is, the top method shows a full bar, and the bottom one shows and empty one?!?

1

There are 1 answers

0
Reanimation On BEST ANSWER

Figured it out. Need to cast my count to float, then divide it as the progress range is 0.0 - 1.0.

-(void)ProgressMade{
    float current = (float)myCount/100; //case 25 and divide 100 = 0.25f
    progress.progress = current;
}