exyte / Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support
MIT License
6.01k stars 553 forks source link

[QUESTION] How can I remove handle action from node? #744

Open sluzhynskyi opened 3 years ago

sluzhynskyi commented 3 years ago

Hey, so the problem is: if I add some action on node with method "onTouchPressed", I can't change that action to another, only append to existed actionArray. So I want to remove action from node or completly change to another, how can I do that?

let node = try! SVGParser.parse(path: "vectorPicture")
let myMacawClass = MacawView(node: node, frame:CGRect.init(x: 0, y: 0, width: 100, height: 100))

func registerForSelection(nodeTag: String) {
        self.myMacawClass.node.nodeBy(tag: nodeTag)?.onTouchPressed({ (touch) in
            let nodeShape = self.myMacawClass.node.nodeBy(tag: nodeTag) as! Shape
            nodeShape.fill = Color.whiteSmoke
        })
    }

["1", "2," "3"].forEach { id in registerForSelection(nodeTag: id)}