我如何知道 CABasicAnimation keyPath 中的值
我发现一些这样的代码:
CABasicAnimation *anim = [CABasicAnimation animation];
anim.keyPath = @"transform.scale";
anim.fromValue = [NSNumber numberWithFloat:1.0];
anim.toValue = [NSNumber numberWithFloat:0];
anim.removedOnCompletion = NO;
anim.fillMode = kCAFillModeBoth;
anim.delegate = self;
[self.view.layer addAnimation:anim forKey:@"scaleOut"];
据
anim.keyPath = @"transform.rotation.x";
我所知, keyPath 是一个链式方法调用。 CALayer 的“transform.scale”是 aLayer.transform.scale。 “transform”是CALayer的一个属性,“scale”是transform的一个“属性”。但CALayer中的属性变换是CATransform3D。
CATransform3D 中没有名为“scale”或“rotation”的属性。
我的问题是: keyPath 如何识别“缩放”和“旋转”?
I find some code like this:
CABasicAnimation *anim = [CABasicAnimation animation];
anim.keyPath = @"transform.scale";
anim.fromValue = [NSNumber numberWithFloat:1.0];
anim.toValue = [NSNumber numberWithFloat:0];
anim.removedOnCompletion = NO;
anim.fillMode = kCAFillModeBoth;
anim.delegate = self;
[self.view.layer addAnimation:anim forKey:@"scaleOut"];
and
anim.keyPath = @"transform.rotation.x";
As far as I know, keyPath is a chained method invoke. "transform.scale" for CALayer is aLayer.transform.scale. "transform" is a property of CALayer, "scale" is a 'property' of transform. But property transform in CALayer is CATransform3D.
There is no property named "scale" or "rotation" in CATransform3D.
My Question is:
How "scale" and "rotation" are identified by keyPath ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Core Animation 扩展了 KVC 以支持对层的某些结构类型属性的字段(或伪字段)的直接寻址。该功能在 键值编码的核心动画扩展。
Core Animation extends KVC to support direct addressing of fields (or pseudo fields) of some struct-type properties of layers. The feature is described in Core Animation Extensions To Key-Value Coding.
我不确定,但我找到了一个可能有帮助的解决方案。
SWIFT:
您可以使用以下命令来代替编写字符串:
当您键入 CALayer 时。 <- 自动完成应该为您提供可用的 keyPaths。
我希望这有帮助。
I'm not sure, but I found a solution that could probably help.
IN SWIFT:
Instead of writing a String you can use this:
When you type CALayer. <- autocomplete should give you the available keyPaths.
I hope this helps.