Skip to content

Instantly share code, notes, and snippets.

@ajn123
Created November 30, 2015 20:14
Show Gist options
  • Select an option

  • Save ajn123/ac564cc79f285e0f28cb to your computer and use it in GitHub Desktop.

Select an option

Save ajn123/ac564cc79f285e0f28cb to your computer and use it in GitHub Desktop.
//: 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