Skip to content

Instantly share code, notes, and snippets.

@KyleGoslan
Created July 26, 2016 10:15
Show Gist options
  • Save KyleGoslan/ee12f09a387871cf602dcfab40dfe08b to your computer and use it in GitHub Desktop.
Save KyleGoslan/ee12f09a387871cf602dcfab40dfe08b to your computer and use it in GitHub Desktop.
UIView extension that returns a UIImage of the view.
func getSnapshotImage() -> UIImage {
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0)
self.drawViewHierarchyInRect(self.bounds, afterScreenUpdates: false)
let snapshotImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return snapshotImage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment