swiftpkcanvasview

SWIFTUI....Is it possible with PKCanvasView


I have created a drawing app. I have the canvas and tools working correctly. I have also added the ability to insert some predefined shapes into the canvas.

My question or where I am running into difficulty is when you use the PKLassoTool() I am unable to size or rotate anything. I am only able to move the selected object around.

Is this by design or are there ways to extend the tool to be able to accomplish the size and rotate aspects?

I haven't been able to find anything that would allow me to accomplish the size and rotate aspects of the PKLassoTool().


Solution

  • class PKLassoTool: PKTool {
    var scale: CGFloat = 1.0  // Scaling factor of the object
    var rotation: CGFloat = 0.0  // Rotation angle of the object
    
    func setScale(scale: CGFloat) {
        self.scale = scale
    }
    
    func setRotation(rotation: CGFloat) {
        self.rotation = rotation
    }
    

    }