问题
Currently I am fetching a random image from the iPad image library and showing it in UIImageView. I want to rotate it by some predefined angle which I can set.
I don't want any touch based rotation. How can I do that?
回答1:
Why not just rotate the UIImageView? Include QuartzCore framework.
#import <QuartzCore/QuartzCore.h>
self.imageView.layer.affineTransform = CGAffineTransformMakeRotation(angle)
See the documentation on CGAffineTransformMakeRotation
回答2:
you can use this one:
CGAffineTransform newTransform = CGAffineTransformMakeRotation((CGFloat)(90 * M_PI / 180.0));
self.imageView.transform = newTransform;
Here 90 in degree, You can use another angle.
回答3:
CGAffineTransform rotateTransform = CGAffineTransformMakeRotation( DEGREES_TO_RADIANS( rotateValue ) );
myObject.transform = rotateTransform;
来源:https://stackoverflow.com/questions/8064200/how-to-rotate-an-image-by-some-angle-which-is-set-by-programmatically