AuthorTravis Kirton
Tags interaction, line, end, point
You can change the end points of a line. Here’s how to attach one to a pan gesture, and then toggle it’s visibility depending on the state of the gesture.
This example uses if-else instead of switch, just because we can.
if-else
switch
let line = Line((Point(), Point())) line.endPoints.0 = canvas.center line.lineWidth = 40.0 canvas.addPanGestureRecognizer { locations, center, translation, velocity, state in line.endPoints.1 = center if state == .Began { self.canvas.add(line) } else if state == .Ended { self.canvas.remove(line) } }