How to programmatically rotate image by 90 Degrees

2019-01-10 21:14发布

Possible Duplicate:
How to Rotate a UIImage 90 degrees?

How to programmatically rotate image by 90 Degrees in iPhone?

3条回答
Fickle 薄情
2楼-- · 2019-01-10 21:40
//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
查看更多
放荡不羁爱自由
3楼-- · 2019-01-10 21:46

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.

查看更多
我命由我不由天
4楼-- · 2019-01-10 21:53

see this:

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

 myImage.center = CGPointMake(0, 0);
 myImage.transform = CGAffineTransformMakeRotation([degreesToRadians:imageRotationFix]);
查看更多
登录 后发表回答