On Sun, Jun 19, 2011 at 11:01 AM, Ken Tozier <kentoz...@comcast.net> wrote: > On Jun 19, 2011, at 1:03 PM, Kyle Sluder wrote: > >> You're mixing conceptual layers here. >> >> CG drawing isn't animated at all. The animation happens at the Core >> Animation layer. When CA asks your layer to -drawInContext: that's an >> atomic operation from CA's perspective. The thing getting animated is >> whatever that context was attached to. > > Not sure I'm following that. Ultimately, the context for all drawing is the > graphics port of the window, but the docs go to great lengths describing all > the ways you can perform extremely granular operations on individual layers > and sublayers. The thing doing the drawing is a subclass of CALayer. What did > you mean by "The thing getting animated is whatever that context was attached > to"?
Core Animation's view of the world ends when it hands you a CGContext and says "fill this with bits." It can't animate the contents of a CGContext because a CGContext really is just an opaque bit receiver and associated drawing state. Even though Core Animation attached the context to a bitmap (or bitmap provider) before handing it to you, the context and the backing store that you're actually drawing into are a black box. All the animations happen at a higher conceptual level. Layers are rotated, translated, scaled, and faded. In the case of an implicit crossfade because of changing a layer's contents property, what CA is actually doing is animating two images that it has previously asked you to fill by asking the layer to -drawInContext: twice: once into the "old" backing store, and once into the "new" backing store. > After trying and failing with the action override, I went back and read the > docs (http://tinyurl.com/CALayerActionForKey) and it sure seems like > returning nil is the correct thing to do. I understand that "actionForKey" > call comes after I do my drawing, but something else is calling that and is > ignoring the nil return, because the stuff I draw in "drawInContext" is > happily animating all sorts of things (like transitions between square and > rounded corners on the path and the size of the image) As I described above, none of this animation is actually happening because of any drawing you're doing in -drawInContext:. Maybe you're seeing a crossfade? > > What is the correct understanding of what he was saying? On a second read, you probably did understand what he was saying about overriding -actionForKey:. I only really see a misconception about -drawInContext:. > > Under the section "Overriding the Duration of Implied Animations", here > (http://tinyurl.com/OverridingImplicitAnimations) it shows the use of > transactions that are basically what I'm doing in my drawInContextSuppressed > method. Since I'm not actually setting a predefined property of the layer, > I'm unclear on where to actually put this transaction... You're setting the contents property of the layer. So returning nil from -actionForKey: should do the trick. I just found this post by Matt Neuburg that might explain why you're having trouble: http://www.cocoabuilder.com/archive/cocoa/293161-calayer-instant-content-update.html Basically, the sentinel value that tells Core Animation to stop looking for an action to apply to a property change is NOT nil, as implied by the documentation and David Duncan's post. Rather, it is NSNull. "nil" means "I don't have an answer for you; consult someone else," which can be the layer _or_ the default set of implicit actions! Rather, try returning [NSNull null] from your -actionForKey: override. --Kyle Sluder _______________________________________________ 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