iPad アプリケーションで、(768, 512) の中心点と 512 の半径を持つ円弧に沿って反時計回りにレイヤーを移動したいと考えています。画面) と 6 時 (右下隅) で終了します。
何度も試行錯誤した後、コードが機能するようになりました
CGPoint origin = logo.layer.position;
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = YES;
CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathMoveToPoint(curvedPath, NULL, origin.x, origin.y);
CGPathAddArc(curvedPath, NULL, 768, 512, 512, -M_PI_2, M_PI_2, YES);
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);
pathAnimation.duration = 2;
[logo.layer addAnimation:pathAnimation forKey:@"curve"];
しかし、問題は、開始角度と終了角度のパラメーターを理解できないことです。それぞれ -M_PI_2 と M_PI_2 を使用し、時計回りを YES に設定する必要があるのはなぜですか?
オブジェクトを反時計回りに 90 度から 270 度に移動していると思うので、コードは次のようになります。
CGPathAddArc(curvedPath, NULL, 768, 512, 512, -M_PI_2, M_PI_2, YES);
私はおそらく複数の場所で間違っており、たまたま正しい結果が得られました。
私を修正し、2 つの角度パラメーターを理解するのを手伝ってください。
開始角度
The angle (in radians) from the horizontal that determines the starting point of the arc.
終了角度
The angle (in radians) from the horizontal that determines the ending point of the arc.
ありがとう
レオ