如何它的动画完成时删除层? [英] How to remove a layer when its animation completes?

查看:207
本文介绍了如何它的动画完成时删除层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我作出的 iOS应用的。我有几个的CALayer 的对象,最终将的删除的由(缩小)的动画的。当完成动画和 animationDidStop:成品被调用时,我想的删除的的的CALayer 超级视图的对象,并将其删除。


  1. 但我怎样才能在的CALayer 对象
    animationDidStop:成品?我早就猜到
    CAanimation -object有一个指针层,但我不能找到它
    在doc。

  2. 有没有更好的方式来处理这个问题? (其实,我有几个动画对象添加到同一层,而且,理想情况下,我想删除该层的最后动画完成,只有当)


解决方案

在你创建动画和设置委托,刚刚通过的CALayer你想与你的动画删除。

作为去除所有的动画,你有两个选择:


  1. 您可以检查您的CALayer的animationKeys任何现有的动画。

  2. 您可以使用CAAnimationGroup和组所有的动画在一起。

I am making an iOS App. I have several CALayer objects that eventually will be deleted by a (shrinking) animation. When the animation is completed, and animationDidStop:finished is invoked, I would like to remove the CALayer object from the super view and delete it.

  1. But how can I get the CALayer object in animationDidStop:finished? I would have guessed that the CAanimation-object had a pointer to the layer, but I can't find it in the doc.
  2. Is there a better way to handle the issue? (Actually, I have several animation objects added to the same layer, and, ideally, I would like to remove the layer only when the last animation completes)

解决方案

When you create the animation and set the delegate, just pass the CALayer you want to remove with your animation.

As for removing all the animations, you have two options:

  1. You can check your CALayer's animationKeys for any existing animations.
  2. You can use a CAAnimationGroup and group all your animations together.

这篇关于如何它的动画完成时删除层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆