开发者

CGAffineTransformRotate in viewDidLoad stretches/distords the UIImageView

I need to rotate by a given angle a UIImageView created by Interface builder when the view is loaded.

- (void)viewDidLoad
{
   [super viewDidLoad];
    image.transform = CGAffineTransformRotate(image.transform, REF_INIT_OFFSET*M_PI/180); 
}

This rotates the image but the latter is totally distorted and stretched. If REF_INIT_OFFSET is a multiple of 90 it works fine !

Here is how the picture should look like (note the needle pointing to the "0")

CGAffineTransformRotate in viewDidLoad stretches/distords the UIImageView

and here is how it actually looks:

CGAffineTransformRotate in viewDidLoad stretches/distords the UIImageView

it looks like the image is stretched into a wrong direction.

Do you 开发者_如何学Pythonhave in idea what's wrong ?

thanks,


Not sure that it help you, but I had the same problem after [UIImage setFrame:] if UIImage was transformed , the decision was using setBounds instead of setFrame

Solving the problem on the discussion in the comments:

Method setFrame is called after viewDidLoad in shouldAutorotateToInterfaceOrientation implicitly if autoresizesSubviews property YES

- (void)viewDidLoad {
[super viewDidLoad];
self.view.autoresizesSubviews=NO;
image.transform = CGAffineTransformRotate(image.transform, 50*M_PI/180);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜