Created
July 26, 2016 10:15
-
-
Save KyleGoslan/ee12f09a387871cf602dcfab40dfe08b to your computer and use it in GitHub Desktop.
UIView extension that returns a UIImage of the view.
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
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