如何在CGAffineTransformRotate之后获取UIImageView的CGRect?

时间:2013-02-07 06:12:49

标签: ios objective-c xcode cgrect

在我的游戏中,我将UIImageview旋转到30度,我需要转换旋转的UIImageview的CGRect,请一些人帮我提供示例代码。

UIImageView *mainImgB = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, width, hight)];
[mainImgB setBackgroundColor:[UIColor greenColor]];
mainImgB.layer.anchorPoint = CGPointMake(0, 0);
mainImgB.center = CGPointMake(View.frame.size.width/2, View.frame.size.height/2);
mainImgB.transform =  CGAffineTransformRotate(mainImgB.transform,30 * M_PI/180); 

由于

1 个答案:

答案 0 :(得分:0)

使用CGRectApplyAffineTransform

 CGRect newRect = CGRectApplyAffineTransform(yourViewOnWhichTransformGetsApplied.frame, yourTransformHere);