获取一组视图围绕一个点旋转
你可以像这样旋转 UIImageView 。
myImage.transform=CGAffineTransformMakeRotation(M_PI/2)
但是如何让一组图像围绕点旋转。假设 8 个 UIButton 排成一圈,绕中心点旋转。
有什么想法吗?
You can rotate an UIImageView like this..
myImage.transform=CGAffineTransformMakeRotation(M_PI/2)
But how do you get a group of images to rotate around point. Say 8 UIButtons arranged in a circle, rotating around a point in the centre.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下
CGAffineTransformMakeTranslation()
转换。您的x
和y
值将是 点沿着一个圆圈。Take a look at the
CGAffineTransformMakeTranslation()
transformation. Yourx
andy
values will be points along a circle.我的建议是将这 8 个 UIButtons 放置在一个包含所有这些 UIButton 的透明超级视图中,然后围绕其中心旋转该超级视图。如果需要调整超级视图的旋转点,可以将其图层的
anchorPoint
属性设置为 (0.5, 0.5) 以外的值。My recommendation would be to place these 8 UIButtons within a transparent superview that encompasses all of them, then rotate that one superview about its center. If you need to adjust the point of rotation for the superview, you can set its layer's
anchorPoint
property to something other than (0.5, 0.5).