开发者

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

This question already has answers here: 开发者_开发技巧 Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜