iPad: Animate UILabels color changing

2019-01-13 08:42发布

I have a label which pops up displaying points in my application. I am using the following code to make the label get larger in scale, then smaller. I would also like to animate the color changing from purple to green. Can someone point me to a resource in achieving this?

mLabel.textColor = [UIColor purpleColor];

 [UIView beginAnimations:nil context:NULL];
 [UIView setAnimationDuration:1.0];
 [UIView setAnimationDelegate:self];
 mLabel.transform = CGAffineTransformMakeScale(1.5,1.5);
 [UIView setAnimationRepeatCount:1];
 mLabel.transform = CGAffineTransformMakeScale(0.5,0.5);
 mLabel.textColor = [UIColor greenColor];
 [UIView commitAnimations];

7条回答
Anthone
2楼-- · 2019-01-13 09:21

Add this before your call to commitAnimations:

[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:mLabel cache:YES];
查看更多
登录 后发表回答