Created
May 18, 2016 03:08
-
-
Save quangtqag/e99a7fd7970caa173fd1e3992a866cc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let image = UIImage(named: "images.jpeg")! | |
UIGraphicsBeginImageContextWithOptions(image.size, false, 1.0) | |
var context = UIGraphicsGetCurrentContext() | |
//move and invert canvas by scaling | |
CGContextTranslateCTM(context, 0, image.size.height) | |
CGContextScaleCTM(context, 1, -1) | |
image.drawInRect(CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)) | |
// move back and reinvert | |
CGContextScaleCTM(context, 1, 1) | |
CGContextTranslateCTM(context, -image.size.width, 0) | |
let flippedImg = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment