Move line (PanGesture) only when (long) pressing on a line. So the UIPanGestureRecognizer need to know the state of UILongPressGestureRecognizer.
Define longPressRecognizer as a property in class DrawView
var longPressRecognizer: UILongPressGestureRecognizer!
Update initializer init?(coder:) accordingly
// let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(DrawView.longPress(_:)))
longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(DrawView.longPress(_:)))
Update moveLine(_ gestureRecognizer: UIPanGestureRecognizer)
print("Recognized a pan")
guard longPressRecognizer.state == .changed || longPressRecognizer.state == .ended else {
return
}