Created
August 30, 2016 02:26
-
-
Save darcwader/d041e40e49bd16f7725ce40b929f7cf4 to your computer and use it in GitHub Desktop.
Resizing Image using UIKit
This file contains 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
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