什么最能解释 CAPropertyAnimationAnimationWithKeyPath: 参数?

发布于 2024-07-28 20:27:02 字数 453 浏览 5 评论 0原文

我想更好地理解这个参数,

+ (id)animationWithKeyPath:(NSString *)keyPath

他们只是说:“要动画的属性的关键路径。”

在一些示例片段中,我看到如下内容:

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

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

是否有用于确定正确的关键路径参数的列表或经验法则? 即,当我想要对帧的宽度进行动画处理时,我必须遵循什么样的规则才能获得正确的关键路径参数字符串?

I'd like to have a better understanding of this parameter in

+ (id)animationWithKeyPath:(NSString *)keyPath

They just say: "The key path of the property to be animated."

In some example snippets I see things like:

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

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

Is there a list or rule of thumb for determining the correct key path parameter? i.e. when I want to animate the width of a frame, what kind of rules would I have to follow to get to the correct key path parameter string?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

∞琼窗梦回ˉ 2024-08-04 20:28:20

CABasicAnimation 动画WithKeyPath 类型

当在 Objective-C 中使用 QuartzCore Framework 中的 CABasicAnimation 时,您必须指定一个 animationWithKeyPath 。 这是一个很长的字符串,不容易在 CABasicAnimationCAPropertyAnimationCAAnimation 类中列出。 我最终在 Apple 的 iPhone OS 参考库的核心动画编程指南中找到了一个方便的图表。 希望这有助于节省某人的时间,至少对我来说是这样。

CABasicAnimation animationWithKeyPath Types

When using the CABasicAnimation from the QuartzCore Framework in Objective-C, you have to specify an animationWithKeyPath. This is a long string and is not easily listed in the CABasicAnimation, CAPropertyAnimation, or the CAAnimation class. I ended up finding a handy chart within the Core Animation Programming guide in Apple’s iPhone OS Reference Library. Hope this helps save someone time, at least it will for me.

姐不稀罕 2024-08-04 20:28:07

我使用过animationWithKeyPath:@“hidden”和animationWithKeyPath:@“strikeEnd”。 它们没有在下面的链接中列出,所以我想一定还有更多。

I have used animationWithKeyPath:@"hidden" and animationWithKeyPath:@"strokeEnd". They are not listed in the link below, So I wonder there must be many more.

海的爱人是光 2024-08-04 20:27:55

要了解什么是“关键路径”,您应该了解一些有关键值编码 (KVC) 的知识。 首先,您应该阅读 键值编码基础知识,但最终您应该通读整个键值编码编程指南。 一旦理解了 KVC,其他概念(例如键值观察(KVO))就会更容易理解。

To understand what a "key path" is, you should learn a little about Key-Value Coding (KVC). To start with, you should read Key-Value Coding Fundamentals, but ultimately you should read through the whole Key-Value Coding Programming Guide. Once you understand KVC, other concepts like Key-Value Observing (KVO) will be much easier to understand.

笨死的猪 2024-08-04 20:27:42

例如,如果您要为 UIView 的图层属性设置动画,请查看 CALayer.h - 在这里您可以找到属性不透明度,并且内联文档提到它是可动画的。 或者 NSView 中的frameOrigin。

对于 iPhone,有很多属性是可动画的:

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

和 Mac:

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

然后还有一些扩展:

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

为您提供:

[CABasicAnimationanimationWithKeyPath:@"transform.scale.x"];

Well for example if you're animating the layer property of a UIView, then check out CALayer.h - here you can find the property opacity, and the inline doc mentions that it is animatable. Or frameOrigin in NSView.

A bunch of properties are animatable, for iphone:

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

and mac:

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

And then there are some extensions:

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

to give you:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文