user930195
user930195

Reputation: 432

How to rotate an image by some angle which is set by programmatically?

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?

Upvotes: 1

Views: 3641

Answers (3)

Sudesh Kumar
Sudesh Kumar

Reputation: 569

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.

Upvotes: 1

rckoenes
rckoenes

Reputation: 69499

Why not just rotate the UIImageView? Include QuartzCore framework.

#import <QuartzCore/QuartzCore.h>

self.imageView.layer.affineTransform = CGAffineTransformMakeRotation(angle)

See the documentation on CGAffineTransformMakeRotation

Upvotes: 2

ader
ader

Reputation: 5393

CGAffineTransform rotateTransform = CGAffineTransformMakeRotation( DEGREES_TO_RADIANS( rotateValue ) );
myObject.transform = rotateTransform;

Upvotes: 1

Related Questions