title: iPhone: How do I add layers to UIView's root layer to display an image with the content property?
body: <p>According to the Mac Dev Center docs, you should be able to set the contents property of a CALayer and have that render automatically. However, I still can't get a simple image to show up by adding a sublayer to the UIView's root later. I've tried multiple different variations; here's what I have so far:</p>
  
  <p>(Note: I know there are other ways of rendering images; for my purposes I'd like to use CALayer's for some of the more complicated stuff I'm going to get into).</p>
  
  <p>(in viewDidDisplay() of the ViewController):</p>
  
  <pre><code> CALayer *theLayer = [CALayer layer];
   [[[self view] layer] addSublayer:theLayer];
   theLayer.contents = (id)[[UIImage imageNamed:@"mypic.png"] CGImage];
   theLayer.contentsRect = CGRectMake(0.0f, 0.0f, 300.0f, 300.0f);
   theLayer.bounds = CGRectMake(0.0f, 0.0f, 300.0f, 400.0f);
  </code></pre>
  
  <p>Anyone know what I'm doing wrong?</p>
  
  <p>Thanks!</p>