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

孤者浪人 提交于 2019-11-26 15:48:25

问题


Possible Duplicate:
How to Rotate a UIImage 90 degrees?

How to programmatically rotate image by 90 Degrees in iPhone?


回答1:


//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



回答2:


see this:

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

 myImage.center = CGPointMake(0, 0);
 myImage.transform = CGAffineTransformMakeRotation([degreesToRadians:imageRotationFix]);



回答3:


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.



来源:https://stackoverflow.com/questions/5581241/how-to-programmatically-rotate-image-by-90-degrees-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!