animationDidStop用于组动画 [英] animationDidStop for group animation
本文介绍了animationDidStop用于组动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个群组动画,但我无法检测到何时点击animationDidStop。我的代码示例:
I have a group animation but I can not detect when hits animationDidStop. example of my code:
[group setDelegate:self];
[view.layer addAnimation:group forKey:@"groupAnimation"];
你们中的任何人都知道我怎么知道群体动画何时完成?
any of you knows how I know when the group animation is done?
推荐答案
您还需要设置animationName属性以匹配,并确保正确定义了委托函数:
You need to also set the animationName property to match, and ensure that your delegate function is properly defined:
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = 2.0f;
group.delegate = self;
[group setValue:@"groupAnimation" forKey:@"animationName"];
[group setAnimations:[NSArray arrayWithObjects:myAnimation, myOtherAnimation, nil]];
[view.layer addAnimation:group forKey:@"groupAnimation"];
。
。
。
. . .
- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)finished
{
if (finished)
{
NSString *animationName = [animation valueForKey:@"animationName"];
if ([animationName isEqualToString:@"groupAnimation"])
{
// your groupAnimation has ended
}
}
}
请注意,对于群组动画,您的组件动画上设置的代表将被忽略。
Please note that with group animations, the delegates set on your component animations will be ignored.
这篇关于animationDidStop用于组动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文