title: How to transform UIBezierPath with UITouch
body: <p>i am trying to change the shape of UIBezierPath that i have created like in this tutorial:
  [<a href="https://www.appcoda.com/bezier-paths-introduction/]" rel="nofollow noreferrer">https://www.appcoda.com/bezier-paths-introduction/]</a>
  thats my code:</p>
  
  <pre><code>class Geometry: UIView {
  
      //var path: UIBezierPath!
      var path = UIBezierPath()
  
      override func draw(_ rect: CGRect) {
          createLine(x: 100, y: 100)
      }
      override init(frame: CGRect) {
          super.init(frame: frame)
  
          self.backgroundColor = UIColor.white
      }
  
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
      }
      func transformShape(x:CGFloat, y:CGFloat)
      {
          path.removeAllPoints()
          createLine(x: x, y: y)
      }
      func createLine(x: CGFloat, y: CGFloat)
      {
          var path = UIBezierPath()
          path.move(to: CGPoint(x: 0.0, y: 0.0))
          path.addLine(to: CGPoint(x: x, y: y))
          path.close()
          path.fill()
          path.stroke()
      }
  
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?)
      {
          let touch = touches.first
          let location = (touch?.location(in: self))!;
          transformShape(x:location.x, y:location.y)
      }
      override func touchesMoved(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?)
      {
          let touch = touches.first
          let location = (touch?.location(in: self))!;
          transformShape(x:location.x, y:location.y)
      }
      override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?)
      {
          let touch = touches.first
          let location = (touch?.location(in: self))!;
          transformShape(x:location.x, y:location.y)
      }
  }
  </code></pre>
  
  <p>i have added the the view in the viewcontroller like this:</p>
  
  <pre><code>import UIKit
  
  var geo = Geometry()
  
  let screenWidth: Int = 1024
  let screenHeight: Int = 768
  
  class ViewController: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
          geo = Geometry(frame: CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight))
          self.view.addSubview(geo)
  
      }
  }
  </code></pre>
  
  <p>to make it easier to understand what i want to do i made this. i want to be able to move the end of both lines to the left and right on x without changing the y-postion</p>
  
  <p><a href="https://i.stack.imgur.com/F7gH7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F7gH7.jpg" alt="enter image description here"></a></p>
  
  <p>i have not found anything besides animation. but thats not what i want to accomplish. the top of the triangle should follow the movements of the finger. thanks </p>