【发布时间】:2010-10-11 19:41:35
【问题描述】:
我有 5 种不同的动画,它们会一个接一个地动画然后消失。有没有办法将它们置于无限循环中,以便动画 #1 开始和结束,然后动画 #2 开始和结束等等。然后整个过程将在无限循环中重复。
我在延迟时将动画放在单独的块中。我猜有更好的方法来做到这一点。这是我目前拥有的:
-(void) firstAnimation {
[UIView beginAnimations:@"Fade Out Image" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:40];
[UIView setAnimationRepeatCount:30];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
theImage.alpha = 1;
theImage.alpha = 0.1;
[UIView commitAnimations];
[self secondAnimation];
}
-(void) secondAnimation {
tapImage2.hidden = NO;
[UIView beginAnimations:@"Fade Out Image" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:53];
[UIView setAnimationRepeatCount:29];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
theImage2.alpha = 1;
theImage2.alpha = 0.1;
[UIView commitAnimations];
[self thirdAnimation];
}
这会持续 5 个动画。感谢您的帮助。
【问题讨论】:
标签: iphone objective-c core-animation infinite-loop