views:

160

answers:

2

Dear All,

Could you please tell me how animate text color of an UILabel?

for example: change color from WHITE to RED then come back to WHITE with fade in effect and repeat in about 3 times.

I need this animation due to my app get real time data from internet, and when value is changed, I need to animate this text value to tell user that it is changed.

Thanks you so much.

+1  A: 

I'm unsure if textColor is animatable on UILabel directly. But if you use a CATextLayer it will be much easier to get this effect,

Joshua Weinberg
Could you please explain more about this, I am a newbie in Iphone development :)
Son Nguyen
Go do a lot of reading on CoreAnimation and CALayers :)
Joshua Weinberg
Thanks so much :(
Son Nguyen
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.htmlIts far too big of a subject to go into it here.
Joshua Weinberg
+1  A: 

This is how I would go about it (long way, but it works):

int i = 0;
while (i <= 3) {
  [UIView beginAnimations:nil context: nil];
  [UIView setAnimationDuration:0.5];
  label.textColor = [UIColor whiteColor];
  [UIView commitAnimations];


  [UIView beginAnimations:nil context: nil];
  [UIView setAnimationDuration:0.5];
  label.textColor = [UIColor redColor];
  [UIView commitAnimations];

  [UIView beginAnimations:nil context: nil];
  [UIView setAnimationDuration:0.5];
  label.textColor = [UIColor whiteColor];
  [UIView commitAnimations];

  ++i;
}
esqew
I have just tried out this way but it's seem the animation is done before it can visible on GUI. I just see the last result on GUI :(
Son Nguyen