1 2 3 4 5 6 7 8
| let image: UIImage? let scale = UIScreen.main.scale UIGraphicsBeginImageContextWithOptions(view.bounds.size, true, scale) if let context = UIGraphicsGetCurrentContext() { view.layer.render(in: context) } image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()
|