Skip to content

Instantly share code, notes, and snippets.

@burhanaksendir
Created July 10, 2015 15:13
Show Gist options
  • Save burhanaksendir/4fd2c3591145de87448b to your computer and use it in GitHub Desktop.
Save burhanaksendir/4fd2c3591145de87448b to your computer and use it in GitHub Desktop.
Save full screenshot including bars - swift
func captureScreen() -> UIImage {
let layer: CALayer = UIApplication.sharedApplication().keyWindow!.layer
let scale: CGFloat = UIScreen.mainScreen().scale
UIGraphicsBeginImageContextWithOptions(layer.frame.size, layer.opaque, scale)
layer.renderInContext(UIGraphicsGetCurrentContext())
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment