UIView、pop和Core Animation区别

一、UIView、pop和Core 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动画应用举例

  1. //弹簧动画
  2. POPSpringAnimation *ani1 = [POPSpringAnimation animationWithPropertyNamed:kPOPViewAlpha];
  3. [self.imgView pop_addAnimation:ani1 forKey:@"anim1"]; //可以通过[self.imgView pop_removeAnimationForKey:@"anim1"];移除该动画
  4. ani1.fromValue = @1.0;
  5. ani1.toValue = @0.0;
  6.  
  7. //基本的属性动画
  8. POPBasicAnimation *anim2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewBackgroundColor];
  9. //anim2.property = [POPAnimatableProperty propertyWithName:kPOPViewBackgroundColor];
  10. [self.imgView pop_addAnimation:anim2 forKey:@"anim2"];
  11. anim2.fromValue = [UIColor greenColor];
  12. anim2.toValue = [UIColor yellowColor];
  13.  
  14. //衰减动画
  15. //POPDecayAnimation *anim3 = [POPDecayAnimation animationWithPropertyNamed:kPOPViewFrame];
  16.  
  17. //自定义动画
  18. //POPCustomAnimation *anim4 = [POPCustomAnimation animationWithBlock:<#^BOOL(id target, POPCustomAnimation *animation)block#>];
  19.  
  20. //延迟动画的方法
  21. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  22.  
  23. {
  24.  
  25. POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
  26.  
  27. anim.springBounciness = ;
  28.  
  29. anim.springSpeed = ;
  30.  
  31. anim.fromValue = [NSValue valueWithCGPoint:CGPointMake(, )];
  32.  
  33. anim.toValue = [NSValue valueWithCGPoint:CGPointMake(, )];
  34.  
  35. [self.sloganView pop_addAnimation:anim forKey:nil];
  36.  
  37. POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
  38.  
  39. anim.beginTime = CACurrentMediaTime() + 1.0; //延迟执行
  40.  
  41. anim.springBounciness = ;
  42.  
  43. anim.springSpeed = ;
  44.  
  45. anim.fromValue = @(self.sloganView.layer.position.y);
  46.  
  47. anim.toValue = @();
  48.  
  49. anim.completionBlock = ^(POPAnimation *anim, BOOL finished){
  50.  
  51. NSLog(@"-----动画结束");
  52.  
  53. };
  54.  
  55. [self.sloganView.layer pop_addAnimation:anim forKey:nil];
  56.  
  57. }

三、pop学习资料

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

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

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

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

  1. //NSObject添加的分类,任何对象都可以调用如下方法
  2. @implementation NSObject (POP)
  3.  
  4. - (void)pop_addAnimation:(POPAnimation *)anim forKey:(NSString *)key
  5. {
  6. [[POPAnimator sharedAnimator] addAnimation:anim forObject:self key:key];
  7. }
  8.  
  9. - (void)pop_removeAllAnimations
  10. {
  11. [[POPAnimator sharedAnimator] removeAllAnimationsForObject:self];
  12. }
  13.  
  14. - (void)pop_removeAnimationForKey:(NSString *)key
  15. {
  16. [[POPAnimator sharedAnimator] removeAnimationForObject:self key:key];
  17. }
  18.  
  19. - (NSArray *)pop_animationKeys
  20. {
  21. return [[POPAnimator sharedAnimator] animationKeysForObject:self];
  22. }
  23.  
  24. - (id)pop_animationForKey:(NSString *)key
  25. {
  26. return [[POPAnimator sharedAnimator] animationForObject:self key:key];
  27. }
  28.  
  29. @end

文章系作者原创,转载请注明出处:http://www.cnblogs.com/stevenwuzheng/p/5523252.html

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

[BS-26] UIView、pop和Core Animation区别的更多相关文章

  1. iOS 动画效果:Core Animation & Facebook's pop

    本文转载至 http://www.cocoachina.com/ios/20151223/14739.html 感谢原创作者分享 前言相信很多人对实现 iOS 中的动画效果都特别头疼,往往懒得动手,功 ...

  2. iOS动画-从UIView到Core Animation

    首先,介绍一下UIView相关的动画. UIView普通动画: [UIView beginAnimations: context:]; [UIView commitAnimations]; 动画属性设 ...

  3. Core Animation编程指南

    本文是<Core Animation Programming Guide>2013-01-28更新版本的译文.本文略去了原文中关于OS X平台上Core Animation相关内容.因为原 ...

  4. 老司机带你走进Core Animation

    为什么时隔这么久我又回来了呢? 回来圈粉. 开玩笑的,前段时间ipv6被拒啊,超级悲剧的,前后弄了好久,然后需求啊什么的又超多,所以写好的东西也没有时间整理.不过既然我现在回来了,那么这将是一个井喷的 ...

  5. iOS——Core Animation 知识摘抄(一)

    本文是对http://www.cocoachina.com/ios/20150104/10814.html文章的关键段落的摘抄,有需要的看原文 CALayer和UIView的关系: CALayer类在 ...

  6. Swift: 深入理解Core Animation(一)

    如果想在底层做一些改变,想实现一些特别的动画,这时除了学习Core Animation之外,别无选择. 最近在看<iOS Core Animation:Advanced Techniques&g ...

  7. iOS开发基础知识:Core Animation(核心动画)

    Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能. Core A ...

  8. iOS之核心动画(Core Animation)

      Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能. Core ...

  9. iOS - Core Animation 核心动画

    1.UIView 动画 具体讲解见 iOS - UIView 动画 2.UIImageView 动画 具体讲解见 iOS - UIImageView 动画 3.CADisplayLink 定时器 具体 ...

随机推荐

  1. Windows下PHPUnit安装

    收藏的介绍地址 1.手动方式安装示例:http://blog.sina.com.cn/s/blog_5d3dc0110100ghlo.html2.通过Pear安装示例:blog.sina.com.cn ...

  2. cms 二级域名修改信息

    \CMS\Collect\PageRes.cs _content = _content.Replace(r.orgurl, newurl); _content = _content.Replace(r ...

  3. [转]超详细图解:自己架设NuGet服务器

    本文转自:http://diaosbook.com/Post/2012/12/15/setup-private-nuget-server 超详细图解:自己架设NuGet服务器 汪宇杰          ...

  4. BKDRhash实现

    参考了一些有关于哈希算法的博客,里面都有提到BKDR哈希算法,在博客:各种字符串Hash函数中有对各种hash算法进行测试,测试关于哈希冲突,以及散列的质量,得到的结果可以参考以上博文. BKDRha ...

  5. MySQL 数据库设计 笔记与总结(4)维护优化

    [维护和优化的工作] ① 维护数据字典 ② 维护索引 ③ 维护表结构 ④ 在适当的时候对表进行水平拆分或垂直拆分 [维护数据字典] a 使用第三方工具对数据字典进行维护 b 利用数据库本身的备注字段来 ...

  6. Rails--bundle exec rake db:migrate

    --新建表: def up create_table :[TABLE_NAME] do |t| t.column :[NUM], :integer t.column :[NAME], :string ...

  7. 耦合 Coupling the object-oriented paradigm && data coupling

    Computer Science An Overview _J. Glenn Brookshear _11th Edition 耦 两个人一起耕地 one of the benefits of the ...

  8. [转]C#之反射

    前言 之所以要写这篇关于C#反射的随笔,起因有两个:   第一个是自己开发的网站需要用到   其次就是没看到这方面比较好的文章. 所以下定决心自己写一篇,废话不多说开始进入正题. 前期准备 在VS20 ...

  9. RTSP 协议分析

    RTSP 协议分析1.概述: RTSP(Real Time Streaming Protocol),实时流传输协议,是TCP/IP协议体系中的一个应用层协议,由哥伦比亚大学.网景和RealNetwor ...

  10. (leetcode)Reverse Linked List 脑子已经僵住

    Reverse a singly linked list. 参考http://www.2cto.com/kf/201110/106607.html 方法1: 讲每个节点的指针指向前面就可以. /** ...