title: How to select an area in a view just touching and dragging in Swift?
body: <p>I need to implement a functionality in my app that allow the user to select an area in an <code>imageView</code> just touching and dragging.</p>
  
  <p>I tried with <code>touchesBegan</code>, but as I am new in Swift I had some difficulty.</p>
  
  <p>How can I do that?</p>
  
  <p>I got here, but what now?</p>
  
  <pre><code>override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      touch = touches.first
      lastPoint = touch.location(in: imageView)
  
      for touch in touches {
          print(touch.location(in: imageView))
      }
  }
  
  override func touchesMoved(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      touch = touches.first
      currentPoint = touch.location(in: imageView)
  
      self.imageView.setNeedsDisplay()
  
      lastPoint = currentPoint
  }
  </code></pre>