Created
September 11, 2017 22:49
-
-
Save francoismarceau29/9d0f61be390c0364dc36d41c5e088458 to your computer and use it in GitHub Desktop.
Resizing a UIImage
This file contains hidden or 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
func resize(image: UIImage, newSize: CGSize) -> UIImage? { | |
UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0) | |
image.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)) | |
let newImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return newImage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment