title: draw a straight line in swift 3 and core graphics
body: <p>I'm trying to draw a single, straight line using core graphics and swift 3 However, when touchesmoved is called, it creates multiple lines instead of just a single line. Code used is below:  </p>
  
  <pre><code>import UIKit
  
      class ViewController: UIViewController {
  
          @IBOutlet weak var drawingPlace: UIImageView!
  
          var startTouch : CGPoint?
          var secondTouch : CGPoint?
  
          override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
              let touch = touches.first
              startTouch = touch?.location(in: drawingPlace)
          }
  
          override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
              for touch in touches{
                  secondTouch = touch.location(in: drawingPlace)
  
                  UIGraphicsBeginImageContext(drawingPlace.frame.size)
                  drawingPlace.image?.draw(in: CGRect(x: 0, y: 0, width: drawingPlace.frame.width, height: drawingPlace.frame.height))
                  let bezier = UIBezierPath()
  
                  bezier.move(to: startTouch!)
                  bezier.addLine(to: secondTouch!)
                  bezier.close()
  
                  bezier.lineWidth = 4
                  UIColor.blue.set()
                  bezier.stroke()
  
                  let img = UIGraphicsGetImageFromCurrentImageContext()
                  UIGraphicsEndImageContext()
                  drawingPlace.image = img   
              }
          }
      }
  </code></pre>
  
  <p>btw touchesEnd creates a single line but only after the user ends the touch. I want the user to see the line being drawn as they touch.
  thank you. </p>