Created
August 5, 2015 07:34
-
-
Save tempire/3e7d759866511c6569c5 to your computer and use it in GitHub Desktop.
Take raw screenshot on ios with swift
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 takeScreenshot(view: UIView) -> UIImageView { | |
UIGraphicsBeginImageContext(view.frame.size) | |
view.layer.renderInContext(UIGraphicsGetCurrentContext()) | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) | |
return UIImageView(image: image) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment