title: CGImage cropping doesn't give the specified rectangle
body: <p>I have a view where you can paint on. I save the minimal and maximal x and y touch-locations to specify the rectangle in which was painted. I tested, if the rectangle was right by adding a view with it as a frame, and everything worked fine. But when I am cropping the image to the rectangle, it gives me some other part.</p>
  
  <pre><code>guard let cg_img = self.asImage().cgImage?.cropping(to: CGRect(x: minX, y: minY, width: maxX-minX, height: maxY-minY)) else { return }
  </code></pre>
  
  <p>My asImage-method:</p>
  
  <pre><code>extension UIView {
      func asImage() -&gt; UIImage {
          let renderer = UIGraphicsImageRenderer(bounds: bounds)
          return renderer.image { rendererContext in
              layer.render(in: rendererContext.cgContext)
          }
      }
  }
  </code></pre>
  
  <p>I probably missed something about the cropping method, but I didn't find anything helpful.</p>