I have been stuck on a situation where I want my code to take a screenshot of the screen but only the middle of it.
@IBAction func savePhoto(_ sender: UIButton) {
// Does not go into program
let size = CGSize(width: view.frame.size.width, height: view.frame.size.height)
UIGraphicsBeginImageContextWithOptions(CGSize(width:1024.0,height: 1024.0), false, UIScreen.main.scale)
view.layer.render(in: UIGraphicsGetCurrentContext()!)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(newImage!, nil, nil, nil)
}
I did try making it to when it screenshots it makes it 1024x1024 and I thought that would work, but it does not.