Re: CALayer Transitions
Re: CALayer Transitions
- Subject: Re: CALayer Transitions
- From: Gordon Apple <email@hidden>
- Date: Mon, 16 Nov 2009 12:35:23 -0600
- Thread-topic: CALayer Transitions
OK, straight out of the core animation guide section on Layer Actions:
====================
"The CALayer class provides default action objectsinstances of CAAnimation,
a CAAction protocol compliant classfor all animatable layer properties.
CALayer also defines the following action triggers that are not linked
directly to properties, as well as the action identifiers in Table 1.
...
A layer replaces an existing layer in a visible layer tree using
replaceSublayer: with:.
The action identifier constant kCATransition
When an action trigger occurs, the layer¹s actionForKey: method is invoked.
This method returns an action object that corresponds to the action
identifier passed as the parameter, or nil if no action object exists.
When the CALayer implementation of actionForKey: is invoked for an
identifier the following search pattern is used:
1. If the layer has a delegate, and it implements the method
actionForLayer:forKey: it is invoked, passing the layer, and the action
identifier as parameters. The delegate¹s actionForLayer:forKey:
implementation should respond as follows: ...."
=================================
Then it searches the action dictionary, etc. BTW, I found other
references to this exact issue through Google. The examples treat VIEW
transitions and layer CONTENT transitions, but not LAYER transitions.
However, the above reference refers specifically to transitioning CALayers
by insert, remove, and replace. So whassup?
I'm now using the delegate method instead of addAnimation:forKey:. It
does work with the "sublayers" key. (Haven't put in the flag yet, but need
it.)
I'm not trying to start an argument, I'm just trying to understand what
I may not understand here. The docs seem clear enough, but it ain't
happening that way.
On 11/16/09 11:23 AM, "Matt Neuburg" <email@hidden> wrote:
> On Sun, 15 Nov 2009 22:38:04 -0600, Gordon Apple <email@hidden> said:
>> What I don't understand, is that, according to the core animation guide,
>> kCATransition seems to be what I want for a key instead of "sublayers". The
>> guide says this is triggered by "replaceSublayer: with:". However, stepping
>> it through, I never see this key come through the delegate.
>
> You seem to be imagining that you can call addAnimation:forKey: and then the
> animation will just lurk there, waiting for something called the "key" to
> come along, and then the animation will trigger. That is not what
> addAnimation:forKey: does, and it isn't what the "key" means.
>
> [Hmmm... The cause of your confusion might be that a view has something
> called defaultAnimationForKey:. It has an animations dictionary, so you can
> install an animation in that dictionary, under a key, and that key will be
> used to hunt to for an animation when a property is changed. But a layer is
> not a view; so that has nothing to do with what we're discussing now.]
>
> As I said before, to see what addAnimation:forKey: does and what the key is,
> look at the Animation section of the Core Animation Programming Guide. The
> animation is performed right now (and in the case of a BasicAnimation,
> *what* it animates is a property, designated by its keypath). The "key" is
> just an arbitrary name to help you refer to this animation later, if needed
> (as in removeAnimation:forKey:).
_______________________________________________
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