title: Swift: UIGraphicsImageRendererFormat instead of UIGraphicsBeginImageContext returning blank image
body: <p>I'm replacing UIGraphicsBeginImageContext with UIGraphicsImageRendererFormat to optimize performance and modernize my code. For some reason, UIGraphicsImageRendererFormat is returning a blank image in my function. I must be doing something wrong!</p>
  
  <p>Old function: (works fine)</p>
  
  <pre><code>func drawImageInRect(inputImage: UIImage, inRect imageRect: CGRect) -&gt; UIImage {
  
      UIGraphicsBeginImageContext(self.size)
      self.draw(in:(CGRect(x:0.0, y:0.0, width:self.size.width, height:self.size.height)))
      inputImage.draw(in:(imageRect))
      let newImage = UIGraphicsGetImageFromCurrentImageContext()
      UIGraphicsEndImageContext()
      return newImage!
  }
  </code></pre>
  
  <p>New function: (draws nothing)</p>
  
  <pre><code>func drawImageInRect(inputImage: UIImage, inRect imageRect: CGRect) -&gt; UIImage {
  
  
      let renderFormat = UIGraphicsImageRendererFormat.default()
      renderFormat.opaque = true
      let renderer = UIGraphicsImageRenderer(size: self.size, format: renderFormat)
  
      let scaledImage = renderer.image {
          (context) in
          inputImage.draw(in: imageRect)
      }
      return scaledImage
  }
  </code></pre>