CGPathAddEllipseInRect中的transform属性
我使用 CGPathAddEllipseInRect 绘制一个圆圈,然后在 CAKeyframeAnimation 中使用它。我的问题是动画总是在同一个位置开始。我认为我可以使用 CGAffineTransform 执行以下操作,使其从不同的点开始:
CGAffineTransform temp = CGAffineTransformMakeRotation(M_PI / 2);
CGPathAddEllipseInRect(animationPath , &temp, rect);
我不知道这是在做什么。当它运行时,我什至看不到动画的这一部分。它正在屏幕外做一些事情。任何帮助理解这一点都会很棒。
I am using CGPathAddEllipseInRect
to draw a circle and then using that in CAKeyframeAnimation. My issue is that the animation always starts in the same spot. I thought that I could do the following with a CGAffineTransform to make it start in a different point:
CGAffineTransform temp = CGAffineTransformMakeRotation(M_PI / 2);
CGPathAddEllipseInRect(animationPath , &temp, rect);
I do not know what this is doing. When it runs, I don't even see this portion of the animation. It is doing something offscreen. Any help understanding this would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,旋转发生在原点 (0,0) 周围,但您想要绕圆心旋转,因此您必须执行额外的变换:
本质上,这会链接三个变换: 首先,圆移动到原点(0,0),然后应用旋转,然后将其移回到原始位置。我做了一些可视化来说明效果:
我选择了正方形而不是圆形,选择了 45° 而不是 90°,以使旋转更容易看到,但原理是一样的。
The rotation happens around the origin (0,0) by default, but you want to rotate around the center of the circle, so you have to do additional transformations:
Essentially, this chains three transformations: First, the circle is moved to the origin (0,0), then the rotation is applied and afterwards it is moved back to its original position. I've made a little visualization to illustrate the effect:
I chose a square instead of a circle and 45° instead of 90° to make the rotation easier to see, but the principle is the same.