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/
Rotate image layer maintaining center
-
07-12-2021 - |
Frage
Consider this image (size is 10x140; arrow is 10x70):
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:
What's could be the problem?
Is the CATransform3DMakeRotation
the problem or the image? The anchor point? the degree formula? Both?
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow