Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

iphone - iPad: Animate UILabels color changing

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];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use iOS 4.0's view transition method to do this:

[UIView transitionWithView:statusLabel duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
    [statusLabel setTextColor:[UIColor whiteColor]];
    [statusLabel setShadowColor:[UIColor blackColor]];
} completion:nil];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...