Problems understanding CALayer geometry
Problems understanding CALayer geometry
- Subject: Problems understanding CALayer geometry
- From: Henri Häkkinen <email@hidden>
- Date: Sat, 21 Nov 2009 17:21:55 +0200
Hello.
I am deriving my own custom CALayer class for my custom NSView class but there is something I don't quite understand about the geometry.
This is how I create the layer in awakeFromNib: of my custom NSView class:
- (void)awakeFromNib {
MyLayer *myLayer = [MyLayer layer];
self.layer = myLayer;
self.wantsLayer = YES;
myLayer.needsDisplayOnBoundsChange = YES;
myLayer.position = CGPointMake(100.0, 100.0);
myLayer.bounds = CGRectMake(0.0, 0.0, 100.0, 100.0);
}
And this is how I draw the layer in MyLayer:
- (void)drawInContext:(CGContextRef)context {
CGContextFillRect(context, [self bounds]);
}
I don't any other methods overidden by neither of the classes.
However the layer somehow automatically gets resized to fill the whole view (that is, the view is rendered completely in black by the CGContextFillRect call). How I understand this, I think it should just draw a 100x100 rectangle at the position (100, 100). What am I missing?
Regards,
Henri Häkkinen
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden