Skip to content

Instantly share code, notes, and snippets.

@vaghul
Forked from darcwader/resize-ui.swift
Created March 20, 2018 08:11
Show Gist options
  • Save vaghul/e3f4e1fa0ac02beb3626f5425584d12a to your computer and use it in GitHub Desktop.
Save vaghul/e3f4e1fa0ac02beb3626f5425584d12a 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