• 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
CATransactions having no effect in CALayer draw delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CATransactions having no effect in CALayer draw delegate


  • Subject: CATransactions having no effect in CALayer draw delegate
  • From: Ken Tozier <email@hidden>
  • Date: Sun, 19 Jun 2011 03:38:55 -0400

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 (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: CATransactions having no effect in CALayer draw delegate
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Porting ResEdit Text Resources to OS X
  • Next by Date: Re: Tab Bar iPad App With Table View
  • Previous by thread: Re: Tab Bar iPad App With Table View
  • Next by thread: Re: CATransactions having no effect in CALayer draw delegate
  • Index(es):
    • Date
    • Thread