I have PKCanvasView in my iPad app. When the user rotates the iPad - I need to scale the Canvas and all the strokes accordingly.
So far I've found two ways to scale a PKCanvasView, first with a .zoomScale:
GeometryReader { geo in
// Canvas View goes here...
}
.onChange(of: geo.size) { newSize in
let canvasScale = newSize.width / myDefaultCanvasWidth
canvasView.minimumZoomScale = canvasScale
canvasView.maximumZoomScale = canvasScale
canvasView.zoomScale = canvasScale
}
Second with CGAffineTransform:
//For short:
let transform = CGAffineTransform(scaleX: scaleWidth, y: scaleHeight)
canvasView.drawing = canvasView.drawing.transformed(using: transform)
Please help me understand the difference between those two methods and which one is correct and preferable?
Thank you.