0

I want to screenshot display out of my app when an event occurred. I read these links( 1, 2, 3) but they aren't for ios 10. I want to know if I can do this.

Thanks

Community
  • 1
  • 1
littleali
  • 408
  • 1
  • 6
  • 22

1 Answers1

0

extension UIView {

public func toImage () -> UIImage {
    UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, 0.0)
    drawHierarchy(in: bounds, afterScreenUpdates: false)
    let img = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return img!
}

}

iOS Developer
  • 437
  • 4
  • 11