如何检测CATransaction触发的动画的完成情况

如何检测CATransaction触发的动画的完成情况

本文介绍了如何检测CATransaction触发的动画的完成情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个CALayer,我只是在控制器的initWithNibName中创建并添加到我的视图控制器主视图的子视图中:
然后,我执行以下动画:

I have a CALayer which I merely create and add to a subview of my view controller's main view in the controller's initWithNibName:And then, I perform the following animation:

  [CATransaction begin];
  [CATransaction setAnimationDuration:2];
  [logoLayer setOpacity:0];
  [CATransaction commit];

如何判断动画何时完成? performSelector:延迟2秒。方法似乎并不是正确的方法。

How can I tell when this animation is done? the performSelector: delayed by 2 secs. approach doesn't seem "the right way" to go about it.

推荐答案

根据, [CATransaction setCompletionBlock:] 可以用于你想要的东西。

According to the doc, [CATransaction setCompletionBlock:] could be used for what you want.

它说

开始动画交易之前,尝试添加类似的东西。

Try adding something like this before you begin the animation transaction.

[CATransaction setCompletionBlock:^{
    // Action after the animation completion
}];

这篇关于如何检测CATransaction触发的动画的完成情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:10