1

I want to show number in a UILabel from an unknown number to unknown number. Suppose from 40 to 699. I want to show this one by one and then break the loop sequence when required number is arrived.

E.g {40,41,42...667,668,669}

I want to remove the previous number from the label and add new number to the label object. I am confuse to use UIAnimation in for() Loop. Does anyone have any idea how to do this?

Syed Qamar Abbas
  • 3,637
  • 1
  • 28
  • 52

1 Answers1

0

Using timer to animation with increase counter.

    int loopCount;
    NSTimer *myTimer;

    // Method that calls your timer.
    - (void)doStuff {

        loopCount++;.
        self.yourLabel.alpha = 0;
        [UIView animateWithDuration:0.65 delay:0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{
        self.yourLabel.alpha = 1;
        } completion:nil];

        if (loopCount >= 669) {
            [myTimer invalidate];
            myTimer = nil;
            self.yourLabel.alpha = 0;
        }
    }

    // Method that kicks it all off
    - (IBAction)startDoingStuff {
        myTimer = [NSTimer scheduledTimerWithTimeInterval:0.75
                                                   target:self
                                                 selector:@selector(doStuff)
                                                 userInfo:nil
                                                  repeats:YES];
    }
Mitul Marsoniya
  • 5,272
  • 4
  • 33
  • 57