第三方库Pop的简单使用

本文介绍了第三方动画库Pop的使用,包括POPSpringAnimation、POPDecayAnimation、POPBasicAnimation的基本创建和应用示例,以及如何使用POPAnimationTracer进行动画跟踪。

最近做一些Demo使用动画的第三方库Pop比较多,在这里和大家分享一下Pop的基本用法。

一、POPSpringAnimation

//1.初始化

POPSpringAnimation *anim = [POPSpringAnimationanimationWithPropertyNamed:kPOPViewFrame];

//2.设置动画的起始位置

anim.fromValue = [NSValuevalueWithCGRect:CGRectZero];

//3.设置动画的终点位置

anim.toValue = [NSValuevalueWithCGRect:self.view.bounds];

//4.给view添加动画(这里想说一下Pop Animation和Core Animation的区别。Core Animation的载体只能是CALayer,而Pop Animation的载体可以使任意的对象)

[view pop_addAnimation:animforKey:@"aim"];(key文档的原文是The key can also be used to query for the existence of an animation,意思是可以使用key去访问另一个已经存在的动画)

二、POPDecayAnimation

1.初始化

POPDecayAnimation *anim = [POPDecayAnimationanimationWithPropertyNamed:kPOPLayerPositionX];//横向动画

2.设置属性

anim.velocity = @(1000);//velocity意味着动画的速度以及距离

3.给view添加动画

[view pop_addAnimation:animforKey:@"slider"];

三、POPBasicAnimation

1.初始化

POPBasicAnimation *anim = [POPBasicAnimationanimationWithPropertyNamed:kPOPViewAlpha];//透明度的变化

2.设置属性

anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];//动画方式

anim.fromValue = @(0.0);//初始值

anim.toValue = @(1.0);//最终值

//3.添加

[self.testViewpop_addAnimation:anim forKey:@"basic"];

四、POPAnimationTracer

POPAnimationTracer *tracer = anim.tracer;

tracer.shouldLogAndResetOnCompletion =YES;

[tracer start];

这个类主要用来记录动画的过程,下面上图

type表示动画目前所处的状态,type = didStop即表示动画执行完毕。value表示动画所运行的距离

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值