关于锚点的问题
所以我最近一直在玩动画并且遇到了锚点。据我了解,锚点默认为 (0.5, 0.5),即视图的中间,您可以更改它,使锚点位于其中一个边框上。我的问题是,如果我希望我的视图围绕视图的超级视图中的特定点旋转,我该如何继续?非常感谢任何帮助
So I have been playing around with animations lately and I've come across the anchor point. I understand that the anchor point is (0.5, 0.5) by default, which is the middle of the view, and you can change it so that the anchor point is on one of the borders. My question is, how do I go on about this if I want my view to rotate around a specific point in the view's superview? Any help is greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看这个问题如何在某一点旋转 CALayer
另外 - 尽管我我猜你可能已经这样做了 - 阅读《核心动画编程指南》,图层几何和变换。
您的问题的不同之处在于您想要指定视图的超级视图中的旋转点。为此,您需要将该超级视图点转换为子视图。您可以按如下方式执行此操作:
给出预期结果 (25.0f, 25.0f)
要使用 CABasicAnimation 旋转 CALayer,请查看此问题的选定答案:具有旋转动画的 CALayer。
Checkout this question how to rotate CALayer at one point
Also - although I guess you've probably already done this - have a read of Core Animation Programming Guide, Layer Geometry and Transforms.
Your question differs in that you want to specify a rotation point that is in your view's superview. To do that, you want to convert that superview point to the subview. You can do that as follows:
Convert that to a point relative to the subview as follows:
That gives the result expected (25.0f, 25.0f)
To rotate a CALayer with a CABasicAnimation, have a look at the selected answer for this question: CALayer with rotation animation.
我自己弄清楚了:我希望锚点位于屏幕左侧边框上,所以我执行了以下操作:
I figured it out myself: I wanted the anchor point to be on the left screen border, so I did the following: