Skip to content

Instantly share code, notes, and snippets.

@tempire
Created August 5, 2015 07:34
Show Gist options
  • Save tempire/3e7d759866511c6569c5 to your computer and use it in GitHub Desktop.
Save tempire/3e7d759866511c6569c5 to your computer and use it in GitHub Desktop.
Take raw screenshot on ios with swift
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