0

Im using UIImageview that moves according to a timer selector. Its center moves a certain x and y axis ammounts. Now I want this image to rotate in time, that means, I need to add a float constant called 'w' which will be the angle that my image will rotate every time the selector runs. I need to know if there is any possible way to access the UIImageView current orientation and modify it.

Jay Bhalani
  • 4,142
  • 8
  • 37
  • 50
Pablo
  • 1

2 Answers2

0

If you need to rotate your UIImageView you can use this

CGAffineTransform transform = CGAffineTransformRotate(imageView.transform, M_PI / 2.0f);
imageView.transform = transform;

use this in your timer method with respect to your current rotation degree.

Agent Chocks.
  • 1,312
  • 8
  • 19
0

First of all;

#define degreesToRadians( degrees ) ( ( degrees ) / 180.0 * M_PI )

this will convert from degrees to radians for transform

this is a method that you should call to turn imageview

-(void)rotateImage
{
    yourImageView.transform = CGAffineTransformMakeRotation(atan2(yourImageView.transform.b, yourImageView.transform.a)+degreesToRadians(delta));
    k++;
}

delta is the amount of rotation. as an angle.

atan2(b,a) gets the current rotation of your imageview. for more detailed answer click

Community
  • 1
  • 1
meth
  • 1,887
  • 2
  • 18
  • 33