博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[BS-26] UIView、pop和Core Animation区别
阅读量:4314 次
发布时间:2019-06-06

本文共 3059 字,大约阅读时间需要 10 分钟。

UIView、pop和Core Animation区别

 

 一、UIView、popCore Animation的主要区别

 1. Core Animation的动画只能添加到layer上(layer.position和view.frame类似)

 2. pop的动画能添加到任何对象

 3. pop的底层并非基于Core Animation, 是Facebook用OC和C++开发的基于CADisplayLink动画

 4. Core Animation的动画仅仅是表象, 并不会真正修改对象的frame\size等值,通常用在不需要与用户交互的动画(如转场动画/下载进度动画)

 5. pop和UIView实现的动画实时修改对象的属性, 真正地修改了对象的属性

 

 二、pop动画应用举例

//弹簧动画    POPSpringAnimation *ani1 = [POPSpringAnimation animationWithPropertyNamed:kPOPViewAlpha];    [self.imgView pop_addAnimation:ani1 forKey:@"anim1"]; //可以通过[self.imgView pop_removeAnimationForKey:@"anim1"];移除该动画    ani1.fromValue = @1.0;    ani1.toValue = @0.0;            //基本的属性动画    POPBasicAnimation *anim2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewBackgroundColor];    //anim2.property = [POPAnimatableProperty propertyWithName:kPOPViewBackgroundColor];    [self.imgView pop_addAnimation:anim2 forKey:@"anim2"];    anim2.fromValue = [UIColor greenColor];    anim2.toValue = [UIColor yellowColor];            //衰减动画    //POPDecayAnimation *anim3 = [POPDecayAnimation animationWithPropertyNamed:kPOPViewFrame];        //自定义动画    //POPCustomAnimation *anim4 = [POPCustomAnimation animationWithBlock:<#^BOOL(id target, POPCustomAnimation *animation)block#>];//延迟动画的方法- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{        POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];        anim.springBounciness = 20;        anim.springSpeed = 20;        anim.fromValue = [NSValue valueWithCGPoint:CGPointMake(100, 100)];        anim.toValue = [NSValue valueWithCGPoint:CGPointMake(200, 200)];        [self.sloganView pop_addAnimation:anim forKey:nil];            POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];        anim.beginTime = CACurrentMediaTime() + 1.0;  //延迟执行        anim.springBounciness = 20;        anim.springSpeed = 20;        anim.fromValue = @(self.sloganView.layer.position.y);        anim.toValue = @(300);        anim.completionBlock = ^(POPAnimation *anim, BOOL finished){            NSLog(@"-----动画结束");        };        [self.sloganView.layer pop_addAnimation:anim forKey:nil];}

 

 

 

三、pop学习资料

1. https://github.com/facebook/pop

2. https://github.com/schneiderandre/popping

3. https://github.com/MartinRGB/LearnCube-iOS

4. POPAnimation给NSObject添加的分类方法

//NSObject添加的分类,任何对象都可以调用如下方法@implementation NSObject (POP)- (void)pop_addAnimation:(POPAnimation *)anim forKey:(NSString *)key{  [[POPAnimator sharedAnimator] addAnimation:anim forObject:self key:key];}- (void)pop_removeAllAnimations{  [[POPAnimator sharedAnimator] removeAllAnimationsForObject:self];}- (void)pop_removeAnimationForKey:(NSString *)key{  [[POPAnimator sharedAnimator] removeAnimationForObject:self key:key];}- (NSArray *)pop_animationKeys{  return [[POPAnimator sharedAnimator] animationKeysForObject:self];}- (id)pop_animationForKey:(NSString *)key{  return [[POPAnimator sharedAnimator] animationForObject:self key:key];}@end

 

文章系作者原创,转载请注明出处:

如有错误,欢迎随时指正!

 

 

 

转载于:https://www.cnblogs.com/stevenwuzheng/p/5523252.html

你可能感兴趣的文章
《java编程思想》读书笔记(一)开篇&第五章(1)
查看>>
swift--调用系统单例实现打电话
查看>>
0038-算一算是一年中的第几天
查看>>
51nod 1094 【水题】
查看>>
虚拟机设置静态IP地址
查看>>
Oracle表或分区导出脚本
查看>>
Springboot上传文件出现MultipartException
查看>>
NHibernate错误:Could not compile the mapping document的解决
查看>>
PHP 之微信小程序支付封装
查看>>
Dynamics CRM SQL转化为FetchXML的在线转化工具
查看>>
Dynamics CRM2011 MspInstallAction failed when installing an Update Rollup
查看>>
找老鼠啊~亏了还是赚了?
查看>>
注意Hibernate4在开发当中的一些改变
查看>>
关于vue的源码调试
查看>>
003.第一个动画:绘制直线
查看>>
vc中的获取时间方式,struct time和time_t(转自百度空间)
查看>>
Civil 3D 中使用COM API导入DEM数据创建曲面
查看>>
spring注解
查看>>
springboot(十八):CORS方式实现跨域
查看>>
打码大致过程
查看>>