【发布时间】:2014-03-05 00:13:02
【问题描述】:
我正在重新向自己介绍 iOS 编程,但遇到了一个看似简单的问题。我一直在关注this example about how to rotate a image according to the user's heading。关键部分是:
float heading = -1.0f * M_PI * newHeading.magneticHeading / 180.0f;
arrowImage.transform = CGAffineTransformMakeRotation(heading);
图像确实旋转了,但中心似乎不是旋转的锚点。我一直在谷歌搜索,但无法弄清楚。有人能指出我正确的方向吗?
看不清楚的截图如下:初始状态下,标签以圆形为中心,白色方块以图像为中心:
【问题讨论】:
-
可以直接设置图层的锚点 view.layer.anchorPoint = anchorPoint;
-
anchorPoint is (0.5, 0.5) 默认情况下,也就是视图的中心。这里还有其他问题,我们需要更多细节。
-
你需要什么样的细节?
标签: ios objective-c uiimageview rotation