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")
and here is how it actually looks:
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);
}
精彩评论