如何知道核心动画动画何时结束

3 animation core-animation

我正在用核心动画做一些动画,但是当动画块完成时我无法通过通知或事件找到方法,就像你在UIVIew动画块中一样

setAnimationDidStopSelector:
Run Code Online (Sandbox Code Playgroud)

我怎么能在核心动画中知道这一点,谢谢你的帮助

Mar*_*pic 7

如果您正在使用CAAnimation实例,请查看animationDidStop:finished:其委托.

CAAnimation * animation = [CAAnimation animation];
animation.delegate = yourDelegate; // could be self, for example.
[yourLayer setAnimation:animation forKey:nil];
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,yourDelegate应该实现animationDidStop:finished:能够检测动画结束的方法.