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

Similar Threads
thread Thread Starter Forum Replies Last Post
Core Animation is so cool! Duncan C iPhone/iPad Programming 8 Mar 8, 2014 04:53 PM
Core Animation -- Nothing Appears Blakeasd Mac Programming 2 Feb 15, 2014 03:25 PM
Core animation: surface is too large...PLEASE HELP? infoseeker OS X 10.8 Mountain Lion 2 Aug 19, 2013 05:34 AM
GLKIT vs Core Animation Layers Blakeasd iPhone/iPad Programming 1 May 25, 2013 10:13 PM
Why is the image animation not appearing? Aptlymade iPhone/iPad Programming 1 Oct 23, 2012 08:45 AM

Forum Jump

All times are GMT -5. The time now is 05:36 AM.

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

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC