Created by CyanHall.com
on 02/04/2021
, Last updated: 03/30/2021.
👉 Star me if it’s helpful.
From StackOverflow: How to Crop image from UIView
👉 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()
More