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?
//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
see this:
Rotate image in Quartz? Image is upside down! (iPhone)
myImage.center = CGPointMake(0, 0);
myImage.transform = CGAffineTransformMakeRotation([degreesToRadians:imageRotationFix]);
this code will rotate the button..
UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setFrame:CGRectMake(100, 100, 200, 44)];
btn.transform=CGAffineTransformMakeRotation(M_PI / -4);
[btn setTitle:@"RakeshBhatt" forState:UIControlStateNormal];
[self.view addSubview:btn];
same way u can rotate imageview.
精彩评论