POP动画引擎是facebook提供的一个开源框架, 可以实现很多的动画效果, 这里就不一一介绍啦, 有兴趣的童鞋请移步:

https://github.com/facebook/pop

下面简单的讲一下POP动画引擎中Layer与CALayer的区别:

这里, 代码做的都是同一个效果: 执行位移动画3秒, 然后在1秒后移除所有动画

使用POP效果图:

使用CALayer效果图:

可以看到, POP执行的动画当动画被移除之后, 被执行对象保留了被停止时的状态

而CALayer执行的动画当动画被移除之后, 跳到了另外一个状态, 这是因为CALayer添加的

CABasicAnimation动画会另外生成一个图层来执行动画, 而CALayer本身早已经是动画结束后状态, 当动画结束后就会显示出来,

所以就会出现, 当动画执行到一半被移除的时候, 就会出现跳动的现象..

这也就是这两者之间的一点区别..

以下是代码:

#import "ViewController.h"
#import <POP.h> @interface ViewController () // 测试CALayer
@property (nonatomic, strong) CALayer *normalLayer;
// 用于测试POP的Layer
@property (nonatomic, strong) CALayer *popLayer; @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad]; } - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{ [self setupNormalLayer]; // 一秒后移除所有动画
[self performSelector:@selector(stopAnimation) withObject:nil afterDelay:.f];
} - (void)setupPopLayer
{
// 初始化
self.popLayer = [CALayer layer];
self.popLayer.frame = CGRectMake(, , , );
self.popLayer.backgroundColor = [UIColor redColor].CGColor;
[self.view.layer addSublayer:self.popLayer];
// 添加POP动画
POPBasicAnimation *basicAnimation = [POPBasicAnimation animationWithPropertyNamed:@"position"];
basicAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.popLayer.position.x, )];
basicAnimation.duration = .f;
[self.popLayer pop_addAnimation:basicAnimation forKey:nil];
} - (void)setupNormalLayer
{
// 初始化
self.normalLayer = [CALayer layer];
self.normalLayer.frame = CGRectMake(, , , );
self.normalLayer.backgroundColor = [UIColor redColor].CGColor;
[self.view.layer addSublayer:self.normalLayer];
// 添加动画
CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
basicAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(self.normalLayer.position.x, self.normalLayer.position.y)];
basicAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.normalLayer.position.x, )];
basicAnimation.duration = .f;
[self.normalLayer addAnimation:basicAnimation forKey:nil]; self.normalLayer.position = CGPointMake(self.normalLayer.position.x, );
} - (void)stopAnimation
{
[self.normalLayer removeAllAnimations];
// [self.popLayer pop_removeAllAnimations];
} @end

POP动画引擎中Layer与CALayer的一点区别的更多相关文章

  1. 用POP动画引擎实现弹簧动画(POPSpringAnimation)

    效果图: #import "ViewController.h" #import <POP.h> @interface ViewController () @proper ...

  2. 用POP动画引擎实现衰减动画(POPDecayAnimation)

    效果图: #import "ViewController.h" #import <POP.h> @interface ViewController () @end @i ...

  3. Xcode7.3.1中通过最新的CocoaPod安装pop动画引擎

    CocoaPod是一个用ruby实现,用于方便的管理Xcode中第三方插件的管理器.用它我们可以很方便的安装和升级插件而不用担心破坏原有的项目. 而pop是一个用于实现App中动画的引擎,它是由Fac ...

  4. 谈谈你对 mysql 引擎中的 MyISAM与InnoDB的区别理解?

    InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定.基本的差别为:MyISAM类型不支持事务处理等高级处理,而InnoDB类型支持.MyISA ...

  5. [译]理解 Windows UI 动画引擎

    本文译自 Nick Waggoner 的 "Understand what’s possible with the Windows UI Animation Engine",已获原 ...

  6. 聊聊动画引擎 pop

    iOS可以通过CADisplayLink实现自定义动画引擎,pop就是基于此实现的,而且比原生Core Animation更强大好用.譬如当ViewController侧滑返回的时候,系统会将Core ...

  7. Unity3d动画脚本 Animation Scripting(深入了解游戏引擎中的动画处理原理)

    也许这一篇文章的内容有点枯燥,但我要说的是如果你想深入的了解游戏引擎是如何处理动画片断或者素材并 让玩家操控的角色动起来栩栩如生,那么这真是一篇好文章(当然我仅仅是翻译了一下)   动画脚本 Anim ...

  8. iOS动画——弹窗动画(pop动画)

    用pop动画简单实现弹窗的缩放和渐变,感觉这个动画常用,就写一下博客 pop动画是Facebook推出的动画引擎,请自行到GitHub上搜索下载拖拽导入xcode项目中. 更多pop动画使用和原理可网 ...

  9. POP动画[1]

    POP动画[1] pop动画是facebook扩展CoreAnimation的,使用及其方便:) 1:Spring系列的弹簧效果(两个动画kPOPLayerBounds与kPOPLayerCorner ...

随机推荐

  1. [Apio2014]回文串

    http://www.lydsy.com:808/JudgeOnline/problem.php?id=3676 这是一道回文树裸题,具体如何建图见http://blog.csdn.net/u0133 ...

  2. h.264 Bi-Predictive Motion Search

    在做B帧的运动预测时,有两组参考图像列表(refList0, refList1),需要进行分别前向预测.后向预测.传统的预测方式是: 对refList0进行前向预测,得到最佳前向ref与mv. 对re ...

  3. ISO14443协议中,卡片对RATS,PPS,IBLOCK的处理约定

    这几天总是看到有人因为这几条规则没处理好,结果检测时通不过,其实看看最新版的ISO14443协议就明白了. 协议中明确要求几条: 1.在激活状态后,如果收到一个无错的RATS命令后,卡片返回atr,此 ...

  4. VS2010中水晶报表应用及实例

    原文:VS2010中水晶报表应用及实例 基本分类如下:第一部分:VS2010简介VS2010是微软的提供的一套完整的开发环境,功能也是相当的大微软宣布了下一代开发工具和平台的正式名称,分别称为“Vis ...

  5. Windows NT 驱动程序开发人员提示 -- 应注意避免的事项

    下面是开发人员在使用 Windows NT 设备驱动程序时应当避免的事项列表: 1.  一定不要在没有标注 I/O 请求数据包 (IRP) 挂起 (IoMarkIrpPending) 的情况下通过调度 ...

  6. -_-#【Angular】工具函数

    AngularJS学习笔记 上下文绑定 var f = angular.bind({a: 'xx'}, function() { console.log(this.a) }) f() // 'xx' ...

  7. Delphi 多线程 “尚未调用CoInitialize错误”的解决方法

    在Delphi  多线程中出现“尚未调用CoInitialize错误”的解决方法 解决方法如下: function  TMyThread.ExecTimer: Boolean;begin  Resul ...

  8. CentOS卸载openoffice

    rpm -e `rpm -qa |grep openoffice` `rpm -qa |grep ooobasis` 这样算是比较彻底的

  9. 什么是Web Service?

    Web service到底是什么:在什么情况下你应该使用Web service. 分布式应用程序和浏览器 研究一下当前的应用程序开发,你会发现一个绝对的倾向:人们开始偏爱基于浏览器的瘦客户应用程序.这 ...

  10. AOP Concepts

    As with most technologies, AOP comes with its own specific set of concepts and terms. It is importan ...