Skip to content

Instantly share code, notes, and snippets.

@almaleh
Last active December 5, 2019 18:51
Show Gist options
  • Save almaleh/e661fc9cffc2e18fc826adbec471902c to your computer and use it in GitHub Desktop.
Save almaleh/e661fc9cffc2e18fc826adbec471902c to your computer and use it in GitHub Desktop.
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let newTouchPoint = touches.first?.location(in: self) else { return }
let lastTouchPoint: CGPoint = line.last ?? .zero
line.append(newTouchPoint)
let rect = calculateRectBetween(lastPoint: lastTouchPoint, newPoint: newTouchPoint)
layer.setNeedsDisplay(rect)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment