Simple example of CALayers in an NSView <p>I am trying to add several CALayers to an NSView but my view remains empty when shown:</p> <p>Here is my code:</p> <pre><code>- (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { self.layer = [CALayer layer]; self.wantsLayer = YES; CALayer *newLayer = [CALayer layer]; NSImage *image = [NSImage imageNamed:@"page.png"]; newLayer.backgroundColor = [NSColor redColor].CGColor; newLayer.contents = (id)[image CGImageForProposedRect:NULL context:NULL hints:nil]; newLayer.frame = NSMakeRect(100,100,100,100);//NSMakeRect(0,0,image.size.width,image.size.height); newLayer.position = CGPointMake(20,20); [self.layer addSublayer:newLayer]; } return self; </code></pre> <p>}</p> <p>DO have any idea (or example of code) to perform this task?</p> <p>Thanks and regards,</p>