Hi all,

I'm looking at Core Animation for the first time. Having a bit of trouble getting started with the simplest set-up I can imagine.

Goal - to add a single CALayer in my view so I can see it. Then, try some simple animations. I've tried a few different things but I just can't see any visible trace of my layer. Here's the code, part of my custom view (actually, almost all of it):

- (id)  initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
        {
                CALayer* rootLayer = [CALayer layer];
                
                theLayer = [CALayer layer];
                
                CGRect          frame = {10,10,110,150};
                CGColorRef      bk = CGColorCreateGenericRGB( 0.5, 0.5, 0, 1.0 
);
                
                [theLayer setCornerRadius:10.0];
                [theLayer setBorderWidth:4.0];
                [theLayer setFrame:frame];
                [theLayer setBackgroundColor:bk];
                
                [rootLayer addSublayer:theLayer];
                
                [self setLayer:rootLayer];
                [self setWantsLayer:YES];
                
                CGColorRelease( bk );
    }
    return self;
}


n.b. 'theLayer' is an ivar.

Initially I didn't have a separate rootLayer, but looking at some sample code it seems most code uses one. Even though there's no layer content set I should see the border and the background colour shouldn't I? What am I missing?

BTW, another things that's a little unclear - when the rootLayer is added to the view, does it adopt the view's frame? Or should I be setting this explicitly? Sample code appears to just let it use its defaults.


thanks for any insight,


Graham
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to