leo*_*leo 11 iphone cocoa-touch core-animation uiviewanimation
在iPad应用程序中,我想沿着一个中心点(768,512)和半径为512的弧逆时针移动一层.我希望它从12点开始(这是一个右上角)屏幕)并在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"];
Run Code Online (Sandbox Code Playgroud)
但问题是我无法理解起始角度和结束角度参数.为什么我应该分别使用-M_PI_2和M_PI_2并将顺时针设置为YES?
我想我正在将物体从90度逆时针移动到270度,因此代码应该是
CGPathAddArc(curvedPath, NULL, 768, 512, 512, -M_PI_2, M_PI_2, YES);
在多个地方我可能错了,偶然得到了正确的结果.
请纠正我并帮助我理解两个角度参数:
由startAngle
The angle (in radians) from the horizontal that determines the starting point of the arc.
Run Code Online (Sandbox Code Playgroud)
endAngle
The angle (in radians) from the horizontal that determines the ending point of the arc.
Run Code Online (Sandbox Code Playgroud)
谢谢
狮子座
C4 *_*vis 18
0的位置在X轴上,如下所示:
3*PI/2
|
PI ---|--- 0
|
PI/2
Run Code Online (Sandbox Code Playgroud)
-PI/2相当于3PI/2.
你有效地在同一个地方开始你的轮换(-PI/2,3*PI/2,5*PI/2等等都相等)
你想到的是"12点钟",它是3*PI/2或-PI/2 ...而你正在向下旋转到"6点钟",这是PI/2
| 归档时间: |
|
| 查看次数: |
4453 次 |
| 最近记录: |