Created
October 28, 2015 17:24
-
-
Save dsowsy/e22f9cb4b6e226b0d714 to your computer and use it in GitHub Desktop.
Snapshot any UIView
This file contains hidden or 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 UIView { | |
| func snapshot() -> UIImage { | |
| UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIScreen.mainScreen().scale) | |
| drawViewHierarchyInRect(self.bounds, afterScreenUpdates: true) | |
| let image = UIGraphicsGetImageFromCurrentImageContext() | |
| UIGraphicsEndImageContext() | |
| return image | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment