Skip to content

Instantly share code, notes, and snippets.

@dbettermann
Last active April 18, 2019 16:53
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbettermann/69ac67f6cbef2c4d7b0a to your computer and use it in GitHub Desktop.
Save dbettermann/69ac67f6cbef2c4d7b0a to your computer and use it in GitHub Desktop.
Take screenshot that includes status bar
extension UIScreen {
class func screenshot() -> UIImage {
let view = mainScreen().snapshotViewAfterScreenUpdates(false)
UIGraphicsBeginImageContext(view.bounds.size)
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
let screenshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return screenshot
}
}
@MusicOnMyMind
Copy link

on simulator it's OK,on the device it would return a white bg pic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment