부드러운 곡선을 따라 애니메이션을 적용하려면 CAKeyframeAnimation을 사용하는 것이 좋습니다. this answer에서 나는 커브를 따라 이미지 뷰를 움직이는 조합 된 애니메이션을위한 코드를 제공하고 크기를 변경하고 페이드 아웃하는 동안 코드를 제공합니다. 이 가로 모드 (두 제어점 뷰의 원점 하나는 상기 디스플레이의 우측 상단 코너에서 서로 곡선을 작성
// Set up path movement
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
CGPoint endPoint = CGPointMake(480.0f - 30.0f, 40.0f);
CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathMoveToPoint(curvedPath, NULL, viewOrigin.x, viewOrigin.y);
CGPathAddCurveToPoint(curvedPath, NULL, endPoint.x, viewOrigin.y, endPoint.x, viewOrigin.y, endPoint.x, endPoint.y);
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);
다음과 같이 그 코드의 관련 부분은). 경로 생성에 대한 자세한 내용은 Quartz 2D Programming Guide 또는 Animation Types and Timing Programming Guide을 참조하십시오.
이 애니메이션을 사용하려면 다음과 같이 사용하여 뷰의 레이어에 추가해야합니다 :
[imageViewForAnimation.layer addAnimation:pathAnimation forKey:@"curveAnimation"];
를 만들 타이밍 기능을 추가 할 수 있습니다 상자의 왼쪽 상단 점의 새로운 좌표를 수학적으로 계산하고 이에 따라 좌표를 변환 하시겠습니까? –
스페인어로 : Parabolicamente;) – Escualo
@James - 줄을 따라 번역하는 것만 알지만, 나는 그것이 대각선에 있기를 원하지 않는다. 나는 그것이 곡선에 있기를 원한다. – bpapa