The solution to do UIImage flipping is with the Objective-C code:
[UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored]   However, imageWithCGImage is not available in Swift! Is there a solution for flipping image horizontally with Swift? Thanks!
Swift 5 Solution For anyone wondering, if you want to flip the image vertically just change context. scaleBy(x: -1.0, y: 1.0) to context. scaleBy(x: 1.0, y: -1.0) .
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
For me the simplest way was to use the .withHorizontallyFlippedOrientation() instance method of UIImage as follows:
 let flippedImage = straightImage.withHorizontallyFlippedOrientation() 
Simple one-liners always make me happy :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With