最近做一些Demo使用动画的第三方库Pop比较多,在这里和大家分享一下Pop的基本用法。
一、POPSpringAnimation
//1.初始化
POPSpringAnimation *anim = [POPSpringAnimationanimationWithPropertyNamed:kPOPViewFrame];
//2.设置动画的起始位置anim.fromValue = [NSValuevalueWithCGRect:CGRectZero];
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];