2009-07-21 1 views
15

私はCAPropertyAnimation animationWithKeyPath:パラメータを最もよく説明するものは何ですか?

+ (id)animationWithKeyPath:(NSString *)keyPath 

に、このパラメータのより良い理解を持っているしたいと思います彼らは言う:「プロパティのキーパスがアニメ化されるように。」私はのようなものを参照いくつかの例のスニペットで

CABasicAnimation *fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; 

CAKeyframeAnimation *animatedIconAnimation = [CAKeyframeAnimation animationWithKeyPath: @"frameOrigin"]; 

は正しいキーパスのパラメータを決定するための親指のリストやルールがありますか?つまり、フレームの幅をアニメーション化したい場合、正しいキーパスのパラメータ文字列に到達するためにはどのようなルールを従わなければなりませんか?

答えて

6

「キーパス」が何であるかを理解するには、Key-Value Coding(KVC)について少し学ぶ必要があります。まず、Key-Value Coding Fundamentalsと読むべきですが、最終的にはKey-Value Coding Programming Guide全体を読む必要があります。一度KVCを理解すると、Key-Value Observing(KVO)のような他の概念がはるかに理解しやすくなります。

18

たとえば、UIViewのレイヤープロパティをアニメートする場合は、CALayer.hをチェックしてください。不透明なプロパティを見つけることができます。インラインドックには、アニメーション可能であることが記載されています。またはNSViewのframeOrigin。

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CoreAnimation_guide/Articles/AnimProps.html#//apple_ref/doc/uid/TP40005942-SW4

そして、いくつかの拡張機能があります:

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreAnimation_guide/AnimatableProperties/AnimatableProperties.html

およびMac:

性質の束は、iPhoneのために、アニメーション可能です

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CoreAnimation_guide/Articles/KVCAdditions.html

あなたに与える:

[CABasicAnimation animationWithKeyPath:@ "transform.scale.x"];

+2

アニメーション化可能なすべてのプロパティへのリンクを更新する:https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreAnimation_guide/AnimatableProperties/AnimatableProperties.html –

0

CABasicAnimation animationWithKeyPathタイプ

Objective-CQuartzCore Frameworkから CABasicAnimationを使用して、あなたは animationWithKeyPathを指定する必要があります。これは長い文字列で、 CABasicAnimation, CAPropertyAnimation、または CAAnimationクラスには簡単にリストされていません。私は、AppleのiPhone OS Reference LibraryのCore Animation Programmingガイドで便利な図を見つけました。これは誰かの時間を節約するのに役立ちます。

から: "隠れた" とanimationWithKeyPath @: "strokeEnd" @http://www.adamzucchi.com/blog/?p=24

0

私はanimationWithKeyPathを使用しています。彼らは以下のリンクには載っていないので、もっとたくさんあるはずですね。

関連する問題