Is it safe to use CABasicAnimation with a keyPath of "frameOrigin"?

I'm trying to do an animation of an NSView's frame using the animator proxy. I'm trying to customize the duration and timing curve, and I need to do this in a way that works on Mac OSX 10.6, so I can't use those extremely juicy-looking methods in NSAnimationContext.

Based on my research, it appears that what I need to do is to create my own CAAnimation object and put it into the animations dictionary for the object I want to animate. This code works great:

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"frameOrigin"];
animation.duration = 1.0;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

[self.myView setAnimations:[NSDictionary dictionaryWithObject:animation forKey:animation.keyPath]];

Then I can go ahead move the view like so:

[[self.myView animator] setFrame:myNewFrame];

This code works great. However, I'm a little concerned that I'm not using the API correctly because of what Apple says about animating the frame property here:

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/AnimatableProperties/AnimatableProperties.html#//apple_ref/doc/uid/TP40004514-CH11-SW1

They say that frame is not an animatable property of a CALayer. Now, I'm not actually directly manipulating the layer, but I presume that the CABasicAnimation object does. So...am I playing with fire here or am I doing it right?

And if I'm doing it wrong, I'd mightily appreciate a pointer on the right way to do it...keeping in mind I can only use 10.6 APIs. Thanks so much!

链接地址: http://www.djcxy.com/p/74184.html

上一篇: 使用CABasicAnimation动画框架属性

下一篇: CABasicAnimation与“frameOrigin”的keyPath一起使用是否安全?