How to Animate UILabel textColor Properties

How to Animate UILabel Properties

 

UILabel properties cannot be easy animated due to some various reasons, so code like this will have no effect on it:this

1
2 3 4 5 6 7 
self.someLabel.textColor = [UIColor blueColor];  [UIView animateWithDuration:0.3  animation:^{   self.someLabel.textColor = [UIColor redColor];  }]; 

But there is a simple solution. Instead of animating property we will perform transition on object itself.spa

Using transitionWithView should solve our problem:code

1
2 3 4 5 6 7 8 9 10 
self.someLabel.textColor = [UIColor blueColor];  [UIView transitionWithView:self.someLabel  duration:0.3  options:UIViewAnimationOptionTransitionCrossDissolve  animations:^{   self.someLabel.textColor = [UIColor redColor];   } completion:nil]; 

This creates nice fade in/out animation which is exactly what we want.orm

相關文章
相關標籤/搜索