I have a problem when I need to rotate UIImageView and resize depending on the mode of Portraite or Landscape.
I managed to get the image to rotate correctly, making the answer in this related problem: Rotate UIImageView depending on the orientation of the iPhone .
This is my code for rotation (now I focus only on turning it to the left):
- (void)rotateImage:(UIImageView *)image duration:(NSTimeInterval)duration
curve:(int)curve degrees:(CGFloat)degrees
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
float angle = DEGREES_TO_RADIANS(degrees);
CGAffineTransform transform = CGAffineTransformRotate(
CGAffineTransformMakeTranslation(
160.0f-self.view.center.x,
240.0f-self.view.center.y
),angle);
image.transform = transform;
[UIView commitAnimations];
}
How I run UIImageView:
UIImage *image = [UIImage imageNamed:@"picture.png"];
self.testImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
self.testImageView.image = image;
self.testImageView.contentMode = UIViewContentModeScaleAspectFit;
self.testImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Now it happens that the image is rotated, but it is the same size as in portrait mode in landscape mode, but concentrated (I understand why, because I made a rotation as an answer to a related question).
, , , , .
UIViewContentModeScaleAspectFit
, , . . ?