title: view.layer drawInContext:UIGraphicsGetCurrentContext() not drawing
body: <p>I am trying to draw a <code>UIView</code> into a <code>UIImage</code>. Here is the code that I'm using:</p>
  
  <pre><code>UIGraphicsBeginImageContextWithOptions(myView.bounds.size, YES, 0.f);
  [myView.layer drawInContext:UIGraphicsGetCurrentContext()];
  UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  </code></pre>
  
  <p>I've verified <code>myView.bounds.size</code> to be valid. <code>myView</code> displays correctly on screen. However, <code>img</code> is completely black (I've tried displaying on both in an <code>UIImageView</code> and tried writing the JPEG representation to file.) The image dimensions are correct, the color space (in JPEG file output) is RGB, color profile is sRGB etc. which means that we're not dealing with a corrupted image (in the sense that image/bitmap data itself is valid). I've tested the case on both 6.0 simulator, 7.0 simulator, and 7.0.6 device, all the same. The layer doesn't have any sublayers, and I've tried setting <code>masksToBounds</code> to <code>NO</code> which didn't change anything.</p>
  
  <p>What could be causing the view's layer not to draw? </p>