Вы можете реализовать обратный вызов touchesMoved в своем подклассе UIView, чтобы сделать это.
func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?)
Эта функция вызывается повторно, пока продолжается касание.
Вот общая идея:
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else {
return
}
let location = touch.location(in: self)
print("x = \(location.x), y = \(location.y)")
}