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

teek

macrumors member
Original poster
Feb 12, 2008
88
0
Norway
I've set up a CALayer for a simple animation.

Code:
	CALayer *monsterLayer = [CALayer layer];
	[monsterLayer setContents:(id)monsterImage.CGImage];
	[monsterLayer setFrame:CGRectMake(0,0,48,48)];
	[monsterLayer setBounds:CGRectMake(0,0,48,48)];
	//[monsterLayer setPosition:CGPointMake(100,100)];
	[monsterLayer setBorderWidth:1.0f];
	[monsterLayer setBorderColor:[UIColor orangeColor].CGColor];
	[monsterLayer addAnimation:animation forKey:@"position"];

	[self.layer insertSublayer:monsterLayer atIndex:0];

	// touch posiotion to trigger animation
	monsterLayer.position = CGPointZero;
   
        NSLog(@"monsterLayer: %@, monsterLayer.bounds);
	NSLog(@"superlayer: %@", monsterLayer.superlayer.bounds);

Both the bounds, frame, contentsRect and all the other possible CGRect properties return nil.

Am I, or rather, what am I doing wrong here ?
 
Ok I feel stupid, again.
That resolved. I am struggeling with getting the current position of the monsterLayer.
The monsterLayer is being animated using a pre-defined CGPath.
Calling contentRect, bounds, frame, or any of the other methods on the layer does not return the x and y of the layer, only the height and width.
Suggestions?
 
I figured it out.

Code:
[[monsterLayer presentationLayer] frame] gives me what I want.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.