When we want to create screenshot programmatically in Ios follow the below code if UIScreen.main.responds(to: #selector(NSDecimalNumberBehaviors.scale)) { //save the screen shot in photos album by using this below line UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) And save the screenshot in photo library then we need to add the Privacy - Photo Library Additions Usage Description in Info.plist file
UIGraphicsBeginImageContextWithOptions(self.view!.bounds.size, false, UIScreen.main.scale)
}
else{
UIGraphicsBeginImageContext(self.view!.bounds.size)
}
self.view?.layer.render(in: UIGraphicsGetCurrentContext()!)
let image : UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
How to make a phone call in iOS 10 using Swift?
How to take a screenshot on iOS programmatically ?
How do i get build/version number of an iOS App?
How to prevent the screen from sleeping in iOS Programmatically?
How can I get battery level and state (plugged in, discharging, charging, etc) in iOS?