Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Basic Core Animation question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic Core Animation question



In your initWithFrame: method you need to retain the layer object or the autorelease pool may deallocate it. Also, where do you set the layer to a view to be displayed?


On Apr 14, 2008, at 6:26 PM, Greg Sabo wrote:

I think I'm doing those things, see below:

//Setting object as delegate for CALayer
- (id) initWithFrame:(NSRect) frame {
    if (self = [super initWithFrame: frame]) {
        animateLayer = [CALayer layer];
        [animateLayer setDelegate:self];
    }
    return self;
}

//drawing the view and setting setNeedsDisplay of CALayer to YES
- (void)drawRect:(NSRect)rect {
[self drawBoardBackgroundInRect:rect];
//whenever this next line is not commented out, the program crashes
//when I try to resize the window
[animateLayer setNeedsDisplay];
}


//Implementation of drawLayer: inContext:
- (void)drawLayer:(CALayer *)theLayer
        inContext:(CGContextRef)theContext {

    CGRect theRect = CGRectMake(0.5, 0.5, 1, 1);
    CGContextSetRGBFillColor(theContext, 1, 0, 1, 1);
    CGContextFillEllipseInRect(theContext, theRect );
}

Thanks for your help, you guys are awesome!
_______________________________________________

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


References: 
 >Basic Core Animation question (From: "Greg Sabo" <email@hidden>)
 >Re: Basic Core Animation question (From: Michael Vannorsdel <email@hidden>)
 >Re: Basic Core Animation question (From: "Greg Sabo" <email@hidden>)
 >Re: Basic Core Animation question (From: Michael Watson <email@hidden>)
 >Re: Basic Core Animation question (From: "Greg Sabo" <email@hidden>)
 >Re: Basic Core Animation question (From: Michael Vannorsdel <email@hidden>)
 >Re: Basic Core Animation question (From: "Greg Sabo" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.