To add a PKCanvasView
inside a UIScrollView
, you can do the following:
First add a UIScrollView
in your view controller's view either from storyboard or programmatically. Set its constraints as required.
Create a PKCanvasView
object and add it as a subview of this UIScrollView
. Don't forget to set its constraints as required.
Set the content size of the UIScrollView
to be equal to the frame size of the PKCanvasView
.
Finally, set the delegate of the PKCanvasView
to be the view controller where you are adding this UIScrollView
. This is required to receive drawing notifications.
main.swift1400 chars35 lines
Note: If you want the user to be able to scroll the UIScrollView
while drawing on the PKCanvasView
, you need to set the delaysContentTouches
property of the UIScrollView
to false
.
gistlibby LogSnag