iOS:核心动画具体的类和协议的介绍

核心动画类CAAnimationCAPropertyAnimation、CABasicAnimation、CAKeyframeAnimation、CATransition、CAAnimationGroup

 
父类:CAAnimation(抽象类)
CAAnimation直接子类:CAPropertyAnimation(抽象类),CATransition(转场动画),CAAnimationGroup(动画数组)
CAPropertyAnimation直接子类:CABasicAnimation(基本动画)、CAKeyframeAnimation(关键帧动画)
=========================================================
类介绍:

@interface CAAnimation : NSObject <NSCoding, NSCopying, CAMediaTiming, CAAction>//动画根抽象类

//速度控制函数(决定动画的运行速率)

@property(strong) CAMediaTimingFunction *timingFunction;

//动画的代理

@property(strong) id delegate;

//默认为YES,代表动画执行完毕后就从图层上移除,图形会恢复到动画执行前的状态

@property(getter=isRemovedOnCompletion) BOOL removedOnCompletion;

//类方法,创建动画实例

+ (instancetype)animation;

//根据指定的键获取对应的属性值

+ (id)defaultValueForKey:(NSString *)key;

//根据指定的键获取的对应的属性是否归档

- (BOOL)shouldArchiveValueForKey:(NSString *)key;

@end

=========================================================

@interface NSObject (CAAnimationDelegate)//NSObject类的一个动画协议分类

//开始动画时触发的方法

- (void)animationDidStart:(CAAnimation *)anim;

//结束动画时触发的方法

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;

@end

=========================================================

@interface CAPropertyAnimation : CAAnimation //抽象类,创建对象必须使用它的子类 

//根据指定的键路径创建一个动画实例

+ (instancetype)animationWithKeyPath:(NSString *)path;

//属性的键路径

@property(copy) NSString *keyPath;

//是否添加

@property(getter=isAdditive) BOOL additive;

//是否累计

@property(getter=isCumulative) BOOL cumulative;

//动画形变函数(形变的transform系数)

@property(strong) CAValueFunction *valueFunction;

@end

=========================================================

注意:核心动画中有一个协议需要注意的:CAMediaTiming   //动画协议

下面是协议对应的一些属性(方法)

//动画开始时间,用来设置动画延迟执行时间

@property CFTimeInterval beginTime;

//动画持续时间
@property CFTimeInterval duration;

//动画执行速率
@property float speed;

//时间执行偏移量
@property CFTimeInterval timeOffset;

//动画重复次数
@property float repeatCount;

//动画重复时间
@property CFTimeInterval repeatDuration;

//如果设置为YES,代表动画每一次重复执行的效果会跟上一次相反

@property BOOL autoreverses;

//动画填充模式(要想fillMode有效,需要设置removedOnCompletion = NO)
@property(copy) NSString *fillMode;

 =========================================================

 @interface CABasicAnimation : CAPropertyAnimation//基本动画

//动画某属性开始值、最终值、经过值(值可能是动画的位置position、形变属性transform等)

@property(strong) id fromValue, toValue, byValue;

@end

 =========================================================

 @interface CAKeyframeAnimation : CAPropertyAnimation //关键帧动画

//存放动画帧的数组

@property(copy) NSArray *values;

//动画运动路径

@property CGPathRef path;

//存放关键时刻的数组,可以为对应的关键帧指定对应的时间点,其取值范围为0到1.0

@property(copy) NSArray *keyTimes;

//速度控制函数(决定动画的运行速率)

@property(copy) NSArray *timingFunctions;

//计算模式,对于每一帧之间的连接模式

@property(copy) NSString *calculationMode;

//存放关键帧时间执行的动画的一些值(position、transform等)

@property(copy) NSArray *tensionValues, *continuityValues, *biasValues;

//旋转模式

@property(copy) NSString *rotationMode;

 @end

 =========================================================

 @interface CATransition : CAAnimation  //转场动画

//动画过渡类型

@property(copy) NSString *type;

//动画过渡方向

@property(copy) NSString *subtype;

//动画起点和动画终点(在整体动画的百分比)

@property float startProgress, endProgress;

//动画过滤

@property(strong) id filter; 

@end

 ========================================================

@interface CAAnimationGroup : CAAnimation //动画数组(存放许多可以同时持续执行的动画)

//存放多张动画的数组

@property(copy) NSArray *animations;

@end

 

原文地址:https://www.cnblogs.com/XYQ-208910/p/4883940.html