Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Dec 2, 2012, 09:54 AM   #1
macrumors newbie
Join Date: Nov 2012
Core animation image not drawn

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:

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.borderColor= CGColorGetConstantColor(kCGColorBlack);
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?
ramy1989 is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 04:33 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC