Created by CyanHall.com on 02/04/2021 , Last updated: 03/30/2021.
👉  github shields Star me if it’s helpful.
    extension UIView {
    func asImage() -> UIImage {
        let renderer = UIGraphicsImageRenderer(bounds: bounds)
        return renderer.image { rendererContext in
            layer.render(in: rendererContext.cgContext)
        }
    }
}

vc.view.asImage()
  
From StackOverflow: How to Crop image from UIView
Maitained by Cyanhall.com, Copy Rights @ CC BY-NC-SA 4.0     ExcelRoadMap