Last active
April 18, 2019 16:53
-
-
Save dbettermann/69ac67f6cbef2c4d7b0a to your computer and use it in GitHub Desktop.
Take screenshot that includes status bar
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 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on simulator it's OK,on the device it would return a white bg pic?