CABasicAnimation CAKeyframeAnimation CAAnimationGroup

layer添加动画

@interface CALayer : NSObject

//layer添加动画
- (void)addAnimation:(CAAnimation *)anim forKey:(nullable NSString *)key;

在上下文中绘制图层

//NSObject的CALayer代理,NSObject对象可自动调用
@interface NSObject (CALayerDelegate)

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx;

CAAnimation

@interface CAAnimation : NSObject

//代理
@property(nullable, strong) id delegate;
//动画完成是否移除
@property(getter=isRemovedOnCompletion) BOOL removedOnCompletion;
//速度控制函数
@property(nullable, strong) CAMediaTimingFunction *timingFunction;
basic.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

//同时设置(1)fillMode = kCAFillModeForwards,(2)removedOnCompletion = NO,可使layer停留在动画结束位置    

kCAFillModeForwards;

@interface NSObject (CAAnimationDelegate)

//动画开始调用
- (void)animationDidStart:(CAAnimation *)anim;
//动画结束调用
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;

@protocol CAMediaTiming

//自动返回初始位置
@property BOOL autoreverses;
//持续时间
@property CFTimeInterval duration;
//开始时间
@property CFTimeInterval beginTime;
//时间偏移
@property CFTimeInterval timeOffset;
//重复时间
@property CFTimeInterval repeatDuration;
//重复次数(若设置重复时间,则无用)
@property float repeatCount;
//速度
@property float speed;
//填充样式
@property(copy) NSString *fillMode;
kCAFillModeForwards;    
kCAFillModeBackwards;
kCAFillModeBoth;
kCAFillModeRemoved;

CAPropertyAnimation

@interface CAPropertyAnimation : CAAnimation


//创建带路径的动画
//path:搜索官方文档CALayer Animatable Properties
//对于transform:可具体设置到x,y,z,如"transform.rotation.x"
+ (instancetype)animationWithKeyPath:(nullable NSString *)path;

CABasicAnimation(基本动画)

@interface CABasicAnimation : CAPropertyAnimation

//起点值
@property(nullable, strong) id fromValue;
//终点值
@property(nullable, strong) id toValue;
//过程值
@property(nullable, strong) id byValue;

CAKeyframeAnimation(关键帧动画)

@interface CAKeyframeAnimation : CAPropertyAnimation

//各个动画点数组
@property(nullable, copy) NSArray *values;
封装颜色对象
(__bridge id)([UIColor orangeColor].CGColor)
封装动画对象
+ (NSValue *)valueWithCATransform3D:(CATransform3D)t;
[NSValue valueWithCATransform3D:CATransform3DMakeScale(2, 2, 2)]

CAAnimationGroup(动画组动画)

@interface CAAnimationGroup : CAAnimation

@property(nullable, copy) NSArray<CAAnimation *> *animations;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值