【问题标题】:CAAnimation delegate in CAAnimationGroupCAAnimationGroup 中的 CAAnimation 委托
【发布时间】:2012-08-27 14:58:36
【问题描述】:

我已将 4 个 CABasicAnimation 分组到 CAAnimationGroup。但问题是

-(void) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag

不是为每个动画调用。

CABasicAnimation *anim1;//code of anim1
anim1.deleagte=self;
CABasicAnimation *anim2://code of anim2
anim2.deleagte=self;
CABasicAnimation *anim3;//code of anim3
anim3.deleagte=self;
CABasicAnimation *anim4://code of anim4
anim4.deleagte=self;

CAAnimationGroup *animGrp;//code of animGrp
animGrp.delegate=self;
[imageView.layer addAnimation:animGrp forKey:@""];

我做错了什么还是有不同的方法。

我的目标是为每个动画更改 UIIImageView 的位置。

所以,当 anim1 结束时,我想更改 Image,但我没有收到 animationDidStop 委托。

【问题讨论】:

    标签: ios delegates caanimation cabasicanimation


    【解决方案1】:

    文档说明

    `CAAnimationGroup` allows multiple animations to be grouped and run concurrently
    

    Note: The delegate and removedOnCompletion properties of animations in the animations property are currently ignored.
    

    只需将beginTime 设置为另一个动画的持续时间,您就可以使用动画的beginTime 在组中的一个动画完成后开始另一个动画。 Time Warp in Animation 很好地解释了从 CAMediaTiming 协议继承的属性。但是,在您的情况下,将一个动画添加到图层并使用委托注册它并在第一个动画完成后将另一个动画添加到图层可能更方便。

    【讨论】:

    • 感谢您的解释。我按照您建议的方式实现了它并且有效。
    猜你喜欢
    • 1970-01-01
    • 2015-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    相关资源
    最近更新 更多