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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to