Skip to content

Instantly share code, notes, and snippets.

@stleamist
Created January 16, 2020 15:53
Show Gist options
  • Save stleamist/5e9ac31248db3653f2ee00e5b469ff7d to your computer and use it in GitHub Desktop.
Save stleamist/5e9ac31248db3653f2ee00e5b469ff7d to your computer and use it in GitHub Desktop.
import UIKit
extension UIView {
func layerImage() -> UIImage {
let renderer = UIGraphicsImageRenderer(bounds: bounds)
let image = renderer.image { context in
layer.render(in: context.cgContext)
}
return image
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment