Good day. Guys, I can't figure out the color change animation for UILable.

[UIView animateWithDuration:6.0 animations:^{ self.view.backgroundColor = [UIColor blackColor]; lblName.textColor = [UIColor grayColor]; }]; 

In this code, smoothly, in 6 seconds I change the background, from any color to black, and it changes smoothly. I also wrote about replacing colors for UILable text and, logically, it should also change smoothly.

But in fact it turns out that UILable instantly changes color. And the background is gradually.

Help to deal with this misfortune!

    2 answers 2

    The UIView backgroundColor property is animated, that is, its animation is supported in the [UIView animateWithDuration: animations:] method ( UIView , section Animations),

    The UILabel textColor property is not animated, that is, you are so simple, just by placing the change in its value in [UIView animateWithDuration: animations:] , you will not get any animation. There are options for how to implement the animation of this property using other approaches.

      The topic is not disclosed! You can replace the UILabel yourself with just a different color. Execute this code and you will get what you wanted:

       [UIView transitionWithView:self.myLabel duration:1 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ self.myLabel.textColor = [UIColor redColor]; } completion:^(BOOL finished) { }]; 

      enter image description here