Created
November 30, 2015 20:14
-
-
Save ajn123/ac564cc79f285e0f28cb to your computer and use it in GitHub Desktop.
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| extension UIImage { | |
| class func scaleImageToSize(img: UIImage, size: CGSize) -> UIImage { | |
| UIGraphicsBeginImageContext(size) | |
| img.drawInRect(CGRect(origin: CGPointZero, size: size)) | |
| let scaledImage = UIGraphicsGetImageFromCurrentImageContext() | |
| UIGraphicsEndImageContext() | |
| return scaledImage | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment