在动画集结束时在MonoTouch中实现CAKeyFrameAnimation回调? [英] Implementing a CAKeyFrameAnimation callback in MonoTouch at the end of an animation set?
问题描述
我的代码的工作原理和我的动画,但我不知道如何做到这一点:
My code works and I animate, but I'm not sure how to do this:
...在MonoTouch中。
...in MonoTouch.
这是我有:
public partial class MyCustomView: UIView
{
// Code Code Code
private void RunAnimation()
{
CAKeyFrameAnimation pathAnimation = new CAKeyFrameAnimation();
pathAnimation.KeyPath = "position";
pathAnimation.Path = trail; //A collection of PointFs
pathAnimation.Duration = playbackSpeed;
Character.Layer.AddAnimation(pathAnimation,"MoveCharacter");
}
//Code Code Code
}
MyCustomView已经从UIView继承,我不能继承自两个类。当动画完成时,我如何调用一个名为AnimationsComplete()的函数?
MyCustomView is already inheriting from UIView and I can't inherit from two classes. How would I call a function called "AnimationsComplete()" when this is done animating?
推荐答案
我的dev机器,但我想你创建一个类从CAAnimationDelegate降序,实现void AnimationStopped(CAAnimation anim,bool finished)方法,然后将这个类的实例分配给pathAnimation.Delegate(在你的示例)。
I'm not in front of my dev machine, but I think you create a class descending from CAAnimationDelegate, implement the "void AnimationStopped(CAAnimation anim, bool finished) method" and then assign an instance of this class to pathAnimation.Delegate (in your sample).
所以,这样的东西(警告 - 未经测试的代码):
So, something like this (warning - untested code):
public partial class MyCustomView: UIView
{
private void RunAnimation()
{
CAKeyFrameAnimation pathAnimation = new CAKeyFrameAnimation();
// More code.
pathAnimation.Delegate = new MyCustomViewDelegate();
}
}
public class MyCustomViewDelegate : CAAnimationDelegate
{
public void AnimationStopped(CAAnimation anim, bool finished)
{
// More code.
}
}
这篇关于在动画集结束时在MonoTouch中实现CAKeyFrameAnimation回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!