title: draw CALayer into a CGContext
body: <p>I have the following code:</p>
  
  <pre><code>CGContextRef context = UIGraphicsGetCurrentContext();
  
  CGContextSaveGState(context);
  
  CALayer *sublayer = [CALayer layer];
  sublayer.backgroundColor = [UIColor orangeColor].CGColor;
  sublayer.cornerRadius = 20.0;
  sublayer.frame = CGRectMake(20, 0, 300, 20);
  
  [sublayer setNeedsDisplay];
  [sublayer drawInContext:context];
  
  UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
  
  UIGraphicsEndImageContext();
  
  return newImage;
  </code></pre>
  
  <p>But when i view the return newImage, there is just an empty image. When i change drawInContext to renderInContext, then i got the above sublayer, but it seems like the coordinate system is mess up.</p>
  
  <p>Any idea why drawInContext on the above did not work?</p>