Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ramy1989

macrumors newbie
Original poster
Nov 7, 2012
21
0
I have opened a similar question on SO but no one answered yet.
I have a CALayer and I'm trying to draw an image inside it:

Code:
NSBundle* mainBundle= [NSBundle mainBundle];
NSString* imagePath= [mainBundle pathForImageResource: @"shark.jpeg"];
NSImage* sharkImage= [[NSImage alloc]initWithContentsOfFile: imagePath];
CALayer* layer=[[CALayer alloc]init];
layer.anchorPoint= CGPointZero;
layer.position= CGPointMake(200, 150);
layer.backgroundColor= CGColorGetConstantColor(kCGColorWhite);
layer.borderWidth=20;
layer.borderColor= CGColorGetConstantColor(kCGColorBlack);
layer.cornerRadius=15;
layer.shadowOpacity=0.5;
view.wantsLayer= YES;
[sharkImage drawInRect: layer.bounds fromRect: NSZeroRect operation: NSCompositeCopy fraction: 1.0];
[CATransaction begin];
[view.layer addSublayer: layer];
[CATransaction commit];

The image is loaded succesfully and I know this through debugging.
But nothing is shown in the layer, why?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.