Replies: 2 comments 5 replies
-
I think what you are trying to achieve is more complex than just "saving"
The current drawing is being processed in the frozenContext variable in the ColoringBookView. So you need to ask the coloring book view to give you a drawing to save whenever you are ready to do it The easiest way is to convert the frozenContext to a CGImage. Check the call to makeImage() in the draw(_ rect: CGRect) method to see how it's done Then you need a file from that image, preferably a PNG file You can do it in two ways. Easiest is to just create a UIImage from it and ask for the pngData() method (check the saveImage method in the ViewController to see how it's done). If you want to create it directly from the CGImage check the createMasks method in the ColoringImage struct, the part where CGImageDestinationCreateWithData is called Now with that file save it somewhere, directly to the documents folder is a good option. Again, check the saveImage method in ViewController to see how it's done
For this, you need to modify the init method of the ColoringBookView, the good news is that it is almost ready for that functionality. |
Beta Was this translation helpful? Give feedback.
-
Yes, seems you also need to call redrawInFrozenContext at the end of your setSavedImage to actually draw the image in the savedImage variable from the start |
Beta Was this translation helpful? Give feedback.
-
Hello,
I asked you how to save an existing drawing to a collectionview to continue redrawing it on twitter, can you guide me how to do it here?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions