CATransaction
+ begin
config current transaction
CATransaction setValue: forKey
kCATransactionAnimationDuration;
kCATransactionDisableActions;
kCATransactionAnimationTimingFunction;
kCATransactionCompletionBlock;
+ commit
[Can nest]
[Only outmost commit begins animating]
Core Animation 默认是打开的
隐式动画
CAAction - Protocol
- All CAAction adopted it
- implement runActionForKey:object:arguments: method
当默认的隐式动画不能满足时,[CATransaction setDisableActions:Yes]
显示动画
CAAnimation - CAAction, CAMediaTiming
一般使用子类
- CAPropertyAnimation
- CABasicAnimation, CAKeyframeAnimation
- CAAnimationGroup
-CATransition
有一个delegate
CABasicAnimation
-animationWithKeyPath:(KVC) animatableProperty
config animation
- fromValue: 默认为当前值
- toValue
- byValue
- duration
- repeatCount (如果想要不停地重复就可以将它设置为 HUGE_VALF)
[在完成之后需要手动设置成目标值(toValue)不然会跳回到原本的值]
CAKeyframeAnimation
它有一个path属性
创建path
_path = CGPathCreateMutable();
CGPathMoveToPoint(_path, NULL, x, y);
CGPathAddArc(_path, Null, x, y, r, 0, M_PI, YES);
CGPathCloseSubPath(_path);
还有一个 timingFunction 的属性
可以设置 = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunction…]
calculationMode 添加差值的不同方法
keyTimes (only for non-paced)
Group Animation: 一个包含 Animation 的 NSArray
group.duration —> 如果时间更长,全部中断
layer - addAnimation:group:forKey:
Timing
每一个layer都是分开计算时间的,所以需要 time converting (好像单位换算)
-convertTime:fromLayer:
-convertTime:toLayer:
nil layer means system time
layer.speed = 0 to pause