HI

I'm writing a subclass of CALayer and what I'm seeing is that regardless of 
whether I wrap CG drawing commands in a CATransaction, or not, it still 
animates. One of the properties of the subclass is a "suppressAnimations" BOOL 
which, if set, is used in the draw method to dispatch the incoming layer and 
context to a  "suppressed" or "normal" draw method. Here's the my drawInContext 
method:

- (void) drawInContext:(CGContextRef) inContext
{
     if (suppressAnimations == YES)
          [self drawInContextSuppressed: inContext];
     else
          [self drawInContextNormal: inContext];
}
 

And here are the "suppressed" and "normal" draw methods

- (void) drawInContextSuppressed:(CGContextRef) inContext
{
     NSLog(@"Entered: drawInContextSuppressed");
     [CATransaction begin];
     [CATransaction setValue:[NSNumber numberWithFloat:0.0f] 
forKey:kCATransactionAnimationDuration];
     [self drawInContextNormal: inContext];
     [CATransaction commit];
} 

- (void) drawInContextNormal:(CGContextRef) inContext
{
     CGPathRef  path = [self bezelPath]; // doesn't do any drawing, just 
generates a CGPathRef
     NSData  *imgData = [properties objectForKey: @"backgroundImage"];
        
     CGContextSaveGState(inContext);
     CGContextBeginPath(inContext);
     CGContextAddPath(inContext, path );
     CGContextEOClip(inContext);
        
     if (imgData != nil)
          [self drawImage: imgData inContext: inContext];
        
     CFRelease(path);
     CGContextRestoreGState(inContext);
}

I tried the suggestion by David Duncan here 
(http://www.cocoabuilder.com/archive/cocoa/279886-calayer-with-no-animation.html)
 and overrode 

- (id) actionForKey:(NSString *) inKey
{
     NSLog(@"actionForKey: %@", inKey);
        
     if ([inKey isEqualToString: @"contents"])
          return nil;
}

But I'm still getting animation.

Anyone see where I'm going 
astray?_______________________________________________

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