Skip to content

Instantly share code, notes, and snippets.

@iosdevie
Created May 26, 2021 07:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iosdevie/4fa5bf6c8d1af5521bd0cc9a995ab0e7 to your computer and use it in GitHub Desktop.
Save iosdevie/4fa5bf6c8d1af5521bd0cc9a995ab0e7 to your computer and use it in GitHub Desktop.
Get UIImage from Pencilkit canvas iOS 13
func preprocessImage() -> UIImage{
var image = canvasView.drawing.image(from: canvasView.drawing.bounds, scale: 10.0)
if let newImage = UIImage(color: .black, size: CGSize(width: view.frame.width, height: view.frame.height)){
if let overlayedImage = newImage.image(byDrawingImage: image, inRect: CGRect(x: view.center.x, y: view.center.y, width: view.frame.width, height: view.frame.height)){
image = overlayedImage
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment