애니메이션 세트의 끝에 모노치에서 케이크 yframeanimation 콜백 구현?
-
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 Machine 앞에 있지 않지만 CaanimationDelegate에서 내려 오는 클래스를 만들고 "void animationstopped (caanimation anim, bool mangeing) 메소드를 구현 한 다음이 클래스의 인스턴스를 pathanimation.delegate (in)에 할당합니다. 샘플).
그래서 이와 같은 것 (경고 - 테스트되지 않은 코드):
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