刚接触CoreAnimation来做动画,发现动画做完了,又回退到初始状态,查了一下文档:发现如下字段,谨以为戒:
CABasicAnimation* move = [CABasicAnimation animationWithKeyPath:@"position.x"];
move.fillMode=kCAFillModeForwards;
move.removedOnCompletion=NO;
1.
Determines if the animation is removed from the target layer’s animations upon completion.
@property(getter=isRemovedOnCompletion) BOOL removedOnCompletion
Discussion
When YES, the animation is removed from the target layer’s animations once its active duration has passed. Defaults to YES.
2.
These constants determine how the timed object behaves once its active duration has completed. They are used with the fillMode property.
NSString * const kCAFillModeRemoved;
NSString * const kCAFillModeForwards;
NSString * const kCAFillModeBackwards;
NSString * const kCAFillModeBoth;
NSString * const kCAFillModeFrozen;
Constants
kCAFillModeRemoved
The receiver is removed from the presentation when the animation is completed.
Available in iOS 2.0 and later.
Declared in CAMediaTiming.h.
kCAFillModeForwards
The receiver remains visible in its final state when the animation is completed.
Available in iOS 2.0 and later.
Declared in CAMediaTiming.h.
kCAFillModeBackwards
The receiver clamps values before zero to zero when the animation is completed.
Available in iOS 2.0 and later.
Declared in CAMediaTiming.h.
kCAFillModeBoth
The receiver clamps values at both ends of the object’s time space
Available in iOS 2.0 and later.
Declared in CAMediaTiming.h.
kCAFillModeFrozen
The mode was deprecated before OS X v10.5 shipped.
Available in iOS 2.0 and later.
Declared in CAMediaTiming.h.