Skip to content

Instantly share code, notes, and snippets.

@dinneo
Forked from darcwader/resize-ui.swift
Created September 11, 2017 15:40
Show Gist options
  • Save dinneo/5e3e9096ecad2a6da615226d1ce1b665 to your computer and use it in GitHub Desktop.
Save dinneo/5e3e9096ecad2a6da615226d1ce1b665 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