Re: ScreenSaverView and Core Animation
Re: ScreenSaverView and Core Animation
- Subject: Re: ScreenSaverView and Core Animation
- From: Brian Christensen <email@hidden>
- Date: Tue, 5 Feb 2008 04:26:02 -0500
On Feb 5, 2008, at 03:17, Brian Williams wrote:
I am trying to get core animation to work with a ScreenSaverView.
The problem is that the layer is nil.
I have tried to setup the coreanimation layer manually but when I
check with
the debugger it comes back empty.
This is in the screensaverview class init
- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
{
self = [super initWithFrame:frame isPreview:isPreview];
if (self) {
self.layer = [CALayer layer];
self.layer.frame = NSRectToCGRect(self.bounds);
self.layer.delegate = self;
self.layer.needsDisplayOnBoundsChange = YES;
self.wantsLayer = YES;
}
return self;
}
In order for your drawLayer:inContext: delegate method to be invoked,
you need to change the frame property after your
"needsDisplayOnBoundsChange = YES" declaration:
self.layer = [CALayer layer];
self.layer.delegate = self;
self.layer.needsDisplayOnBoundsChange = YES;
self.layer.frame = NSRectToCGRect(self.bounds);
self.wantsLayer = YES;
As it stands with your original code, you're changing the bounds
before you're telling it that you want it to redisplay when the bounds
are changed.
/brian
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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