旋转图像层维护中心

时间:2012-12-13 20:16:42

标签: iphone objective-c ios uiimageview catransform3d

考虑这张图片(尺寸为10x140;箭头为10x70):

Circle from 0 to 160° degrees

红色箭头是我的问题,因为我想让它旋转。

现在我正在使用

CGFloat Angle = [Speed.text intValue] / 160.0;
_Arr.layer.transform = CATransform3DMakeRotation(Angle * M_PI * 2, 0, 0, 1);

_Arr旋转时,它会失去中心。如图所示,中心是加号(“+”),不透明的箭头是问题。

我也尝试设置中心和锚点,但我得到了相同的结果。 我把箭头图像加倍(双倍高,图像一半),同样的事情。

这是界面构建器:

Interface builder

可能是什么问题?

问题或图片是CATransform3DMakeRotation吗?锚点?学位公式?都?

1 个答案:

答案 0 :(得分:1)

anchorPoint是答案(“将箭头中心点移动到图像的一个端点”)。查看本教程http://www.mobisoftinfotech.com/blog/iphone/ios-tutorial-custom-speedometer-control/