To add text using PKCanvasView, you can use the UIGraphicsImageRenderer class to create a UIImage representation of the PKCanvasView's current drawing, and then add the text to the image. Here is an example of how to add text to a PKCanvasView:
main.swift1435 chars34 lines
In this example, we first create a UIImage representation of the PKCanvasView's current drawing using the UIGraphicsImageRenderer class. We then create a mutable copy of the image, and add text to it using a CATextLayer. Finally, we create a new UIImage from the modified context, and set it as the PKCanvasView's drawing.
Note that this is just one way to add text to a PKCanvasView, and there may be other methods that are more suitable for your specific use case.
gistlibby LogSnag