Search code examples
objective-ciosrotationanchorcatransform3d

Rotate image retaining center?


I have this sample image

enter image description here

i need to block the center in the middle of the circle when i rotate.
What's the anchor point? It's the anchor point the problem?

Now the image rotate, unconsidering the anchor point.

_Image.layer.anchorPoint = CGPointMake(0.5, 0.5); //?
[...]
CGFloat wAngle = Degrees2Radians([_Weight.text intValue]/300.0*360);
_Image.layer.transform = CATransform3DMakeRotation (wAngle+M_PI, 0, 0, 1);

I need to make a test, like an inverse clockwise starting from 0 to 300, retaining the center.

0, arrow to bottom
150, arrow to top
300, arrow to bottom
etc...

thanks.


Solution

  • This is by default

    _Image.layer.anchorPoint = CGPointMake(0.5, 0.5); //
    

    Use something like CGPointMake(0.5, 0.25)

    U will need to calculate where u want to set. These are not exact values