【发布时间】:2014-01-20 09:53:59
【问题描述】:
这是一些我纠结了一段时间的代码。
如果您启动淡入动画,标签文本会淡入。 如果我开始淡出动画,标签文本就会淡出。
当我启动startFade 方法时,只显示淡出。在启动fadeOut 方法之前,如何等待fadeIn 方法视觉完成。
-(IBAction)startFade:(id)sender{
[self fadeIn];
[self fadeOut];
}
-(IBAction)fadeIn:(id)sender{
[self fadeIn];
}
-(IBAction)fadeOut:(id)sender{
[self fadeOut];
}
-(void) fadeIn{
[_label setAlpha:0];
[UILabel beginAnimations:NULL context:nil];
[UILabel setAnimationDuration:2.0];
[_label setAlpha:1];
[UILabel commitAnimations];
}
-(void) fadeOut{
[UILabel beginAnimations:NULL context:nil];
[UILabel setAnimationDuration:2.0];
[_label setAlpha:0];
[UILabel commitAnimations];
}
【问题讨论】:
-
你尝试过基于块的动画吗?
标签: ios cocoa-touch core-animation