CATransaction
+ begin
config current transaction
CATransaction setValue: forKey
kCATransactionAnimationDuration;
kCATransactionDisableActions;
kCATransactionAnimationTimingFunction;
kCATransactionCompletionBlock;
+ commit
[Can nest]
[Only outmost commit begins animating]
Core Animation 默認(rèn)是打開的
隱式動畫
CAAction - Protocol
- All CAAction adopted it
- implement runActionForKey:object:arguments: method
當(dāng)默認(rèn)的隱式動畫不能滿足時,[CATransaction setDisableActions:Yes]
顯示動畫
CAAnimation - CAAction, CAMediaTiming
一般使用子類
- CAPropertyAnimation
- CABasicAnimation, CAKeyframeAnimation
- CAAnimationGroup
-CATransition
有一個delegate
CABasicAnimation
-animationWithKeyPath:(KVC) animatableProperty
config animation
- fromValue: 默認(rèn)為當(dāng)前值
- toValue
- byValue
- duration
- repeatCount (如果想要不停地重復(fù)就可以將它設(shè)置為 HUGE_VALF)
[在完成之后需要手動設(shè)置成目標(biāo)值(toValue)不然會跳回到原本的值]
CAKeyframeAnimation
它有一個path屬性
創(chuàng)建path
_path = CGPathCreateMutable();
CGPathMoveToPoint(_path, NULL, x, y);
CGPathAddArc(_path, Null, x, y, r, 0, M_PI, YES);
CGPathCloseSubPath(_path);
還有一個 timingFunction 的屬性
可以設(shè)置 = [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