문제

내 코드는 작동하고 애니메이션이지만 어떻게 해야할지 잘 모르겠습니다.

Calayer의 애니메이션 엔드 콜백?

... 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.
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top