Flipping a UIImage
Sep 25, 2011
Flipping an image using objective-c is so easy once you know how...
1//Create a normal image UIImage* img = [UIImage imageNamed:@"myImage.png"]; //Flip it UIImage* flippedImage = [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored];
That's it! Now to have it as an method we can use more conveniently, try this:
1-(UIImage *)flipImage:(UIImage *)img { UIImage* flippedImage = [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored]; return flippedImage; }
Then we can send any image to it and it will return a flipped version.