title: Getting black (empty) image from UIView drawViewHierarchyInRect:afterScreenUpdates:
body: <p>After successfully using <code>UIView</code>’s new <code>drawViewHierarchyInRect:afterScreenUpdates:</code> method introduced in iOS 7 to obtain an image representation (via <code>UIGraphicsGetImageFromCurrentImageContext()</code>) for blurring my app also needed to obtain just a portion of a view. I managed to get it in the following manner:</p>
  
  <pre><code>UIImage *image;
  
  CGSize blurredImageSize = [_blurImageView frame].size;
  
  UIGraphicsBeginImageContextWithOptions(blurredImageSize, YES, .0f);
  
  [aView drawViewHierarchyInRect: [aView bounds] afterScreenUpdates: YES];
  
  image = UIGraphicsGetImageFromCurrentImageContext();
  
  UIGraphicsEndImageContext();
  </code></pre>
  
  <p>This lets me retrieve <code>aView</code>’s content following <code>_blurImageView</code>’s frame.</p>
  
  <p>Now, however, I would need to obtain a portion of <code>aView</code>, but this time this portion would be “inside”. Below is an image representing what I would like to achieve. </p>
  
  <p><img src="https://i.stack.imgur.com/2GbZq.png" alt=""></p>
  
  <p>I have already tried creating a new graphics context and setting its size to the portion’s size (red box) and calling <code>aView</code> to draw in the rect that represents the red box’s frame (of course its superview’s frame being equal to <code>aView</code>’s) but the image obtained is all black (empty).</p>