title: remove all drawing in imageview UIGraphicsGetImageFromCurrentImageContext
body: <p>I want to remove everything written imageview pic. I have tried something like pic.Clear() but its not being recognized. I dont know what else to do. The only other thing I can think off is to somehow create a variable that is like a line because I cant access the lines right now outside of the func they are in now. I am trying to do this is in clearM. Using UIGraphicsGetImageFromCurrentImageContext has something to do with this. I dont want to use pencil kit.</p>
  <pre><code>import UIKit
  class ViewController: UIViewController {
      var startPoint: CGPoint?
      var statPoint = CGPoint.zero
      var swipe = false
      var pic = UIImageView()
      var clearBtn = UIButton()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          [pic,clearBtn].forEach {
              $0.translatesAutoresizingMaskIntoConstraints = false
              view.addSubview($0)
          }
          pic.backgroundColor = .brown
          clearBtn.backgroundColor = .blue
          pic.frame = CGRect(x: 100, y: 100, width: 250, height: 250)
          clearBtn.frame = CGRect(x: 100, y: 350, width: 50, height: 50)
          clearBtn.addTarget(self, action: #selector(clearM), for: .touchDown)
      }
      
      @objc func clearM(){
      
          
      }
      
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          guard let touch = touches.first else {
              return}
          swipe = false
          statPoint = touch.location(in: self.pic)
      }
  
      var score = 0
  
      func drawLine(from fromPoint: CGPoint, to toPoint : CGPoint)  {
          UIGraphicsBeginImageContext( pic.frame.size)
          
          guard let context = UIGraphicsGetCurrentContext() else {
              return
          }
          
          pic.image?.draw(in: pic.bounds)
          context.move(to: fromPoint)
          context.addLine(to: toPoint)
          context.setLineCap(.round)
          context.setLineWidth(5)
     
          context.setStrokeColor(UIColor.black.cgColor)
          context.strokePath()
          
          pic.image = UIGraphicsGetImageFromCurrentImageContext()
          pic.alpha = 1
  
          UIGraphicsEndImageContext()
      }
  
      override func touchesMoved(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          guard let touch = touches.first else {
              return
          }
          swipe = true
          let currentPoint = touch.location(in: pic)
          drawLine(from: statPoint, to: currentPoint)
          statPoint = currentPoint
      }
  
      override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          if !swipe {
              drawLine(from: statPoint, to: statPoint)
          }
          UIGraphicsBeginImageContext(pic.frame.size)
          pic.image?.draw(in: pic.bounds, blendMode: .normal, alpha: 1)
          pic.image = UIGraphicsGetImageFromCurrentImageContext()
          UIGraphicsEndImageContext()
      }
  }
  </code></pre>