Q:

Animate UILabel text

I'm new to iOS programming and i've got a question:
I want to make a kind of custom progress bar. I've created 2 UIViews, one above the other and animated the front UIView with this code:
[UIView animateWithDuration:1.5f delay:1.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
       [barCima setFrame:CGRectMake(10, 300, value, 30)];
    }
                     completion:nil];

But now, I would like to do something more. I want that while the width bar is growing, a UILabel appears with the current value. Example: I set de value to 300. While the animation is occurring, the UILabel is showing the progress until it reaches the 300 (1, 2, 3, 4, 5, 6, 7,...,300).

A:

You need an NSTimer that fires every one second or so, and a counter. Whenever the NSTimer fires, the counter is incremented, and UILabel's text will be updated. It should look like this
int _counter; // An instance var

self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:nil repeats: YES];
// Be sure you call [self.timer invalidate] when you don't need it anymore

...

-(void)timerFired {
    ++ _counter;
    self.label.text = [NSString stringWithFormat:@"%i", _counter];
}

Good luck thought I don't know what you use such a progress bar for!

