• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting started with Core Animation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting started with Core Animation


  • Subject: Getting started with Core Animation
  • From: Graham Cox <email@hidden>
  • Date: Tue, 3 Jun 2008 13:51:49 +1000

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 (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


  • Follow-Ups:
    • Re: Getting started with Core Animation
      • From: Matt Long <email@hidden>
  • Prev by Date: Re: trying to glue a cocoa ui to a pthread application / subclassing nsview
  • Next by Date: A little extra cash...
  • Previous by thread: Re: Keyboard Layout Services
  • Next by thread: Re: Getting started with Core Animation
  • Index(es):
    • Date
    • Thread