Skip to content

Instantly share code, notes, and snippets.

@kvermeille
Created April 6, 2016 13:37
Show Gist options
  • Save kvermeille/9f53c208f75bfd587e1f37ed0ca5829f to your computer and use it in GitHub Desktop.
Save kvermeille/9f53c208f75bfd587e1f37ed0ca5829f to your computer and use it in GitHub Desktop.
extension UIImage {
convenience init(view: UIView) {
UIGraphicsBeginImageContext(view.frame.size)
view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.init(CGImage: image.CGImage!)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment