前言
在Core Animation中 我们经常使用CABasicAnimation或者它的子类做一些动画
一般情况下我们都要用到Keypath,最近在研究动画,想整理一下所有可用的Keypath在iOS的核心动画中.
CALayer的相关属性
废话不多说 我们上一段代码演示一下 这篇的主题
CABasicAnimation * scaleAnimation = [CABasicAnimation animation];
scaleAnimation.keyPath = @"transform.scale.x";
scaleAnimation.fromValue = @(1.0f);
scaleAnimation.toValue = @(1.0f * ScreenWidth);
一般我们给一个View的Layer添加animation
[xxxView.layer addAnimation: scaleAnimation forKey:@"testAnimationName"];
这里面我们注意到scaleAnimation.keyPath
它实际上是一个字符串 是一个被外部修改的成员变量的类似的东西,但是我们自己又不能随便想写写啥
这个实际上是一个layer的属性 或者成员变量.
全部可修改的keypath有哪些呢?
CALayer animatable properties 动画有如下这些
nchorPoint
backgroundColor
backgroundFilters
borderColor
borderWidth
bounds
compositingFilter
contents
contentsRect
cornerRadius
doubleSided
filters
frame
hidden
mask
masksToBounds
opacity
position
shadowColor
shadowOffset
shadowOpacity
shadowPath
shadowRadius
sublayers
sublayerTransform
transform
zPosition