Skip to content

Instantly share code, notes, and snippets.

@shaulhameed
Created April 17, 2017 13:17
Show Gist options
  • Save shaulhameed/63cf194d3608002a887bfcccbd8f68c5 to your computer and use it in GitHub Desktop.
Save shaulhameed/63cf194d3608002a887bfcccbd8f68c5 to your computer and use it in GitHub Desktop.
Capture view
extension UIView {
var captureView: UIImage {
get {
let size = self.bounds.size
UIGraphicsBeginImageContextWithOptions(size, false, 0);
self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
let image:UIImage = UIGraphicsGetImageFromCurrentImageContext()!;
UIGraphicsEndImageContext();
return image
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment