Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically rotate image by 90 Degrees in iPhone? [duplicate]

Possible Duplicate:
How to Rotate a UIImage 90 degrees?

How to programmatically rotate image by 90 Degrees in iPhone?

like image 355
Parth Bhatt Avatar asked Apr 07 '11 12:04

Parth Bhatt


People also ask

How do I rotate my Uiimage?

So, Let's get started, Step 1 − Open Xcode→SingleViewApplication→name it RotateImage. Step 2 − Open Main. storyboard, add UIImageView and add 2 buttons as shown below name them ROTATE BY 90 DEGREES AND ROTATE BY 45 DEGREES.


2 Answers

//create rect UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_image.png"]];  //set point of rotation myImageView.center = CGPointMake(100.0, 100.0);  //rotate rect myImageView.transform = CGAffineTransformMakeRotation(M_PI_2); //rotation in radians 
like image 124
Sabobin Avatar answered Sep 28 '22 00:09

Sabobin


see this:

Rotate image in Quartz? Image is upside down! (iPhone)

 myImage.center = CGPointMake(0, 0);  myImage.transform = CGAffineTransformMakeRotation([degreesToRadians:imageRotationFix]); 
like image 28
Ahmad Kayyali Avatar answered Sep 28 '22 02:09

Ahmad Kayyali