Created
May 31, 2016 16:18
-
-
Save mbarriault/82aaee5bef05fc73919a3115a7bb7f64 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 scaledImage: UIImage | |
do { | |
UIGraphicsBeginImageContextWithOptions(size, false, 0.0) | |
defer { | |
UIGraphicsEndImageContext() | |
} | |
// Fill background | |
UIColor.blackColor().setFill(); UIRectFill(CGRect(origin: .zero, size: size)) | |
// Draw scaled image | |
let drawingRect: CGRect = CGRect( | |
origin: drawingOrigin, | |
size: CGSize(width: scaledWidth, height: scaledHeight)) | |
image.drawInRect(drawingRect) | |
// Fetch image | |
scaledImage = UIGraphicsGetImageFromCurrentImageContext()! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment