CyanHall.com 创建于 2021-02-04, 上次更新:2021-03-30。
👉  github shields 如果有用请点赞。
    extension UIView {
    func asImage() -> UIImage {
        let renderer = UIGraphicsImageRenderer(bounds: bounds)
        return renderer.image { rendererContext in
            layer.render(in: rendererContext.cgContext)
        }
    }
}

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