Created
July 7, 2015 20:34
-
-
Save naturaln0va/c47d246e0e5d608be803 to your computer and use it in GitHub Desktop.
Get a UIImage of the contents of a UIView
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
extension UIView | |
{ | |
func imageByCapturing() -> UIImage | |
{ | |
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0) | |
self.drawViewHierarchyInRect(self.frame, 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