2

我已将 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 委托。

4

1 回答 1

3

该文件指出

`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动画。动画中的时间扭曲CAMediaTiming很好地解释了从协议继承的属性。但是,在您的情况下,将一个动画添加到图层并使用委托注册它并在第一个动画完成后将另一个动画添加到图层可能更方便。

于 2012-09-04T10:35:56.387 回答