I believe the only animatable properties are the ones explicitly
labeled "animatable" in the documentation. That is why (I believe)
there is a section labeled "Animatable Properties" in the Core
Animation Programming guide. I think the reason is that you can't
guarantee that your custom property is something that can be
interpolated.
The only way that you can trigger an action for a custom key is to
explicitly change the value for that key--which is why your call to
[content setValue:[NSNumber numberWithInt:19] forKey:@"test"]; works.
It is also why it worked when you specified bounds.size.width as this
is an actual animatable property.
Hope that helps.
-Matt
On Oct 20, 2008, at 9:58 AM, Patrick Mau wrote:
Good afternoon,
I have implemented a layer-based view that acts as the layer
delegate and defines a layer action named "test".
Afterwards I create a CABasic animation to animate the test
property. If you look at the line marked 'THIS WORKS",
you'll see that sending "setValue:forKey" triggers a message
"runActionForKey:object:arguments",
but using the property for a basic animation will not trigger the
CAAction.
So here's my simple question. What is needed to "animate" a generic
property named test?
Did I mis-read the documentation and wrongly assumed that any
property can be used as
long as there's a CAAction?
By the way, changing the "keyPath" to something like
"bounds.size.width" works as expected.
/* Get the CAAction for "test", or nil for all others */
- (id<CAAction>) actionForLayer:(CALayer *)theLayer forKey:(NSString
*)theKey
{
id res = [theLayer.actions valueForKey:theKey];
NSLog(@"actionForLayer:%p forKey:\"%@\" = %p", theLayer, theKey,
res);
return res;
}