在动画集的末尾实现在MonoTouch的一个CAKeyFrameAnimation回调?
-
19-09-2019 - |
题
我的代码工作,我的动画,但我不知道如何做到这一点:
...在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()”时,这样做动画?
解决方案
我不是在我的dev的机器面前,但我认为你创建一个类从CAAnimationDelegate下降,实施“空缺AnimationStopped(CAAnimation阿尼姆,布尔完)方法”,然后指定这个类的一个实例来pathAnimation。委托(在样品中)。
所以,是这样的(警告 - 未测试的代码强>):
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.
}
}
不隶属于 StackOverflow