Reputation: 3600
I'm trying to figure out how to rotate the image of an image view and determine the direction it is facing.
I know I can rotate the UIImageView like this
imagView.transform = CGAffineTransformMakeRotation(1.57079633);
Upvotes: 0
Views: 849
Reputation: 3798
UIImage *yourImageHere;
switch (imageView.image.imageOrientation)
{
case UIImageOrientationUp:
newImage=[UIImage imageWithCGImage:[imageView.image CGImage] scale:1.0f orientation:UIImageOrientationLeft];
imageView.contentMode=UIViewContentModeScaleAspectFit;
break;
case UIImageOrientationLeft:
newImage=[UIImage imageWithCGImage:[imageView.image CGImage] scale:1.0f orientation:UIImageOrientationDown];
imageView.contentMode=UIViewContentModeScaleAspectFill;
break;
case UIImageOrientationDown:
newImage=[UIImage imageWithCGImage:[imageView.image CGImage] scale:1.0f orientation:UIImageOrientationRight];
imageView.contentMode=UIViewContentModeScaleAspectFit;
break;
case UIImageOrientationRight:
newImage=[UIImage imageWithCGImage:[imageView.image CGImage] scale:1.0f orientation:UIImageOrientationUp];
imageView.contentMode=UIViewContentModeScaleAspectFill;
break;
default:
break;
}
imageView.image=newImage;
May this helps you
Upvotes: 5