Rotate UIImage or UIView by a certain angle, NOT the number of angles

Objective-C for iOS.

How do I rotate an image or look at a certain angle. I tried the two methods below, but both rotate AMOUNT angle, not angle. Basically, I would like to call the method to rotate 90 ', and then repeat the call 180', and finish the image / view 180 ', DO NOT add both of them (270'), which happens if I use any of the following methods.

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

myImage.transform = CGAffineTransformMakeRotation(degreesToRadians(90));

myImage.transform = CGAffineTransformRotate(myImage.transform, degreesToRadians(90));

Many thanks!

+5
source share
2 answers

Reset

.transform = CGAffineTransformIdentity

before another conversion ...

+6
source

ohho , . :

[UIView animateWithDuration:0.2 animations:^{
            self.compassImgView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, radians);
        }];
+1

All Articles