[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:0];
[UIView commitAnimations];
//This delegate is called after the completion of Animation.
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[infoLbl setAlpha:1];
[UIView commitAnimations];
}
Insetad,如果您使用的是 NStimer Selecor,那么您不尝试更改 uilabel 文本的颜色吗?像:
-(void)timerSelector
{
if([textLabel textColor] == [UIColor blackColor])
{
[textLabel setTextColor:[UIColor grayColor]];
}
else
{
[textLabel setTextColor:[UIColor blackColor]];
}
}
上述方法将使您能够很容易地在循环中淡入/淡出。