Consider this image (size is 10x140; arrow is 10x70):

Circle from 0 to 160° degrees

The Red arrow is my problem, because I want it to rotate.

Now I'm using

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

When _Arr rotates, it loses the center. As you see in the picture, the center is the plus ("+") sign, and the arrows in opaque are the problems.

I tried also to set center and anchor point, but I get the same results. I made the arrow image double (double heigth, image half), same thing.

This is the interface builder:

Interface builder

What's could be the problem?

Is the CATransform3DMakeRotation the problem or the image? The anchor point? the degree formula? Both?

有帮助吗?

解决方案

anchorPoint is the answer ("Shift the arrow center point to one of the end points of the image"). Check this tutorial http://www.mobisoftinfotech.com/blog/iphone/ios-tutorial-custom-speedometer-control/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top