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动画应用举例

    //弹簧动画
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 = ; anim.springSpeed = ; anim.fromValue = [NSValue valueWithCGPoint:CGPointMake(, )]; anim.toValue = [NSValue valueWithCGPoint:CGPointMake(, )]; [self.sloganView pop_addAnimation:anim forKey:nil]; POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY]; anim.beginTime = CACurrentMediaTime() + 1.0; //延迟执行 anim.springBounciness = ; anim.springSpeed = ; anim.fromValue = @(self.sloganView.layer.position.y); anim.toValue = @(); 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

文章系作者原创,转载请注明出处: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. 漫谈Java虚拟机(JVM)

    Java 虚拟机(JVM)是可运行 Java 代码的假想计算机. 只要根据 JVM 规范描述将解释器移植到特定的计算机上,就能保证经过编译的任何 Java 代码能够在该系统上运行. 从上图中不难明白J ...

  2. HDU 1007 Quoit Design(二分+浮点数精度控制)

    Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  3. OC中属性及方法

    1.声明式属性    a.实例变量    b.声明属性        自动生成setter/getter方法        .h ->@property 属性类型 属性名;        .m ...

  4. Javascript 笔记与总结(1-6)Javascript 面向对象

    在 JavaScript 中,有对象,没有类(但有构造函数). 在 JavaScript 中,对象不依赖于类而存在,可以直接生成. {key:value, key:value} 这种格式的对象,成为 ...

  5. JMS相关概念

    1.相关概念 1)JMS jms即Java消息服务(Java Message Service) 是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息 ...

  6. 8.PHP内核探索:再次探讨SAPI

    在PHP的生命周期的各个阶段,一些与服务相关的操作都是通过SAPI接口实现. 这些内置实现的物理位置在PHP源码的SAPI目录.这个目录存放了PHP对各个服务器抽象层的代码, 例如命令行程序的实现,A ...

  7. spring mvc配置文件dispatcher-servlet.xml详解

    Spring的配置文档<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="ht ...

  8. php读取memcahed java session

    PHP 共享 JAVA 保存的session信息 情景: 1:现在有两个系统,一个是Java做的系统,一个是PHP的系统,现在要把两个系统弄成一个单点登录. 2:两个系统两个库,两个库的表结构完全不同 ...

  9. nrf51822裸机教程-UART

    art硬件模块通常都有内置的硬件接收buff,比如51822的硬件uart模块图如下 因为通常接收到uart数据时都会做一些处理.比如保存到数据,或者对数据做一些判断之类的. 如果uart的波特率设置 ...

  10. mysql-zabbix-agent

    使用Zabbix监控MySQL服务器方法 01/27/2014 从Zabbix 2.2开始,Zabbix官方已经支持了MySQL监控,但是MySQL监控默认是不可用的,需要经过额外的设置才可以使用.K ...