Skip to content

Instantly share code, notes, and snippets.

@darcwader
Created August 30, 2016 02:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save darcwader/d041e40e49bd16f7725ce40b929f7cf4 to your computer and use it in GitHub Desktop.
Save darcwader/d041e40e49bd16f7725ce40b929f7cf4 to your computer and use it in GitHub Desktop.
Resizing Image using UIKit
extension UIImage {
func resizeUI(size:CGSize) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, true, self.scale)
self.drawInRect(CGRect(origin: CGPointZero, size: size))
let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return resizedImage
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment