title: Crop an image in swift
body: <p>I'm building an image cropping system, and here is a basic simplification of the 3 elements in a view controller i organized to achieve this:</p>
  
  <pre><code> @IBOutlet weak var containerView: UIView! // contains the 2 elements below
  
   @IBOutlet weak var originalImage: UIImageView! //fit in 100% space of above container
  
   @IBOutlet weak var imageGrabber: UIView! //Rectangle on top of originalImage
  </code></pre>
  
  <p>So we have a container containing image originalImage. Container is resized so image occupies the entire space. Then, we have a rectangle view imageGrabber on top of the image.
  The goals here are:</p>
  
  <p>1) Grab rectangle coordinate from the imageGrabber, determined from its position in containerView.</p>
  
  <p>2) Crop originalImage from those rectangle coordinate</p>
  
  <p>So the final result, is a cropped image, corresponding to the area covered by imageGrabber.</p>
  
  <p>Do you know a way to accomplish these ?</p>