首次结束动画后触发其他动画(Objective-C) [英] Triggering other animation after first ending Animation (Objective-C)
本文介绍了首次结束动画后触发其他动画(Objective-C)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的动画,只需修改按钮的位置:
I have a simple animation which simply modify the position of a button:
[UIView beginAnimation:nil context:nil];
[UIView setAnimationsDuration:3.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
mybutton.frame = CGREctMake(20, 233, 280, 46);
[UIView commitAnimations];
我想在这个完成后执行其他一些动画,怎么做?
I want to perform some other animations when this one is finish, how to do that?
推荐答案
获取开始的代码段..设置初始(第一个)动画:
a code segment for getting start.. setup initial (the first) animation:
- (void) aniPath:(AnimationPath *) path
{
[UIView beginAnimations:path->aniname context:path];
[UIView setAnimationDuration:path->interval];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(aniDone:finished:context:)];
// your initial animation
[UIView commitAnimations];
}
完成第一个动画后链接到另一个动画:
chains to another animation when the first is done:
- (void) aniDone:(NSString *) aniname finished:(BOOL) finished context:(void *) context
{
AnimationPath *path = (AnimationPath *) context;
if ([aniname isEqualToString:path->aniname]) {
[UIView beginAnimations:path->aniname context:context];
[UIView setAnimationDuration:path->interval];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(aniDone:finished:context:)];
// more animations, even recursively
[UIView commitAnimations];
}
}
这篇关于首次结束动画后触发其他动画(Objective-C)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文