iosobjective-cipaduilabelcaanimation

Animate text change in UILabel


I'm setting a new text value to a UILabel. Currently, the new text appears just fine. However, I'd like to add some animation when the new text appears. I'm wondering what I can do to animate the appearance of the new text.


Solution

  • Here is the code to make this work.

    [UIView beginAnimations:@"animateText" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    [UIView setAnimationDuration:1.0f];
    [self.lbl setAlpha:0];
    [self.lbl setText:@"New Text";
    [self.lbl setAlpha:1];
    [UIView commitAnimations];