iPadアプリケーションでは、中心点が(768,512)、半径が512の円弧に沿って反時計回りにレイヤーを移動したいと考えています.12時に開始します(画面の右上にあります)、6時に終了します(右下)。問題を理解しているCGPathAddArc
した後、多くの私は
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に設定するのはなぜですか?
私は複数の場所で、おそらく間違っていると、偶然に正しい結果を得たので、コードが
CGPathAddArc(curvedPath, NULL, 768, 512, 512, -M_PI_2, M_PI_2, YES);
する必要があり、私は270度、反時計回りに90度からオブジェクトを移動すると思います。
私を修正し、私は2つの角度パラメータを理解してください:
startAngleの
The angle (in radians) from the horizontal that determines the starting point of the arc.
endAngle
The angle (in radians) from the horizontal that determines the ending point of the arc.
おかげ
レオ
逆さまのy軸が私を混乱させます。また、ありがとう、それは私を助けた:) – codrut