Created
October 17, 2016 09:28
-
-
Save zhaorui/016f7f91726d05803762b0d1df05ddd4 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: "car.jpg") | |
let hasAlpha = false | |
let scale: CGFloat = 0.0 // Automatically use scale factor of main screen | |
UIGraphicsBeginImageContextWithOptions(CGSize(width: 80, height:80), !hasAlpha, scale) | |
image?.draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: 80, height: 80))) | |
let scaledImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment