Created
May 18, 2016 02:51
-
-
Save quangtqag/de9232d80831eff09569ea4aba4b15eb 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")! | |
let degrees: Double = 90 | |
let rads = CGFloat(M_PI * degrees / 180) | |
UIGraphicsBeginImageContext(CGSizeMake(image.size.height, image.size.width)) | |
let ctx = UIGraphicsGetCurrentContext() | |
CGContextTranslateCTM(ctx, image.size.height/2, image.size.width/2) | |
CGContextRotateCTM(ctx, rads) | |
CGContextScaleCTM(ctx, 1.0, -1.0) | |
CGContextDrawImage(ctx, CGRectMake(-image.size.width/2, -image.size.height/2, image.size.width, image.size.height), image.CGImage) | |
let flippedImg = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment