title: Cannot get CALayer to display in UIView
body: <p>I have a simple, single-view app and for some reason I cannot get a <code>CALayer</code> to display in the app's <code>UIView</code>. The background color of the view is correct but the image in the <code>CALayer</code> is not visible. I've stepped through the code in the debugger and I'm sure that the image is being loaded correctly. If instead of using a <code>CALayer</code> I use a <code>UIImageView</code> everything works as you'd expect.</p>
  
  <p>Here is the code from my <code>UIViewController</code> subclass. Do you see what I'm doing wrong?</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.view.backgroundColor = [UIColor darkGrayColor];
  
      CALayer* cardLayer = [self layerForCard];
  
      [self.view.layer addSublayer:cardLayer];
  }
  
  - (CALayer *)layerForCard
  {
      UIImage* cardImage = [UIImage imageNamed:@"card1.jpg"];
      CGSize cardSize    = cardImage.size;
      CGRect cardRect    = CGRectMake(.0, .0, cardSize.width, cardSize.height);
  
      // Container Layer
      CALayer *containerLayer = [CALayer layer];
      containerLayer.bounds   = cardRect;
      containerLayer.opacity  = 1.0;
  
      // Image Layer
      CALayer *imageLayer = [CALayer layer];
      imageLayer.bounds = cardRect;
      imageLayer.contentsGravity = kCAGravityResizeAspectFill;
      imageLayer.contents = CFBridgingRelease(cardImage.CGImage);
  
      [containerLayer addSublayer:imageLayer];
  
      return containerLayer;
  }
  </code></pre>