Facebook POP 进阶指南

本文转自Kevin Blog
Facebook 在发布了 Paper 之后,似乎还不满足于只是将其作为一个概念性产品,更进一步开源了其背后的动画引擎 POP,此举大有三年前发布的 iOS UI 框架 Three20 的意味。而 POP 开源后也不负 Facebook 的厚望。



- POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
- anim.toValue = [NSValue valueWithCGPoint:CGPointMake(2.0, 2.0)];
- anim.springBounciness = 4.0;
- anim.springSpeed = 12.0;
- anim.completionBlock = ^(POPAnimation *anim, BOOL finished) {
- if (finished) {NSLog(@"Animation finished!");}};
- POPDecayAnimation *anim = [POPDecayAnimation animWithPropertyNamed:kPOPLayerPositionX];
- anim.velocity = @(100.0);
- anim.fromValue = @(25.0);
- //anim.deceleration = 0.998;
- anim.completionBlock = ^(POPAnimation *anim, BOOL finished) {
- if (finished) {NSLog(@"Stop!");}};

- POPBasicAnimation *anim = [POPBasicAnimation animation];
- anim.duration = 10.0;
- anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- POPAnimatableProperty * prop = [POPAnimatableProperty propertyWithName:@"count" initializer:^(POPMutableAnimatableProperty *prop) { prop.readBlock = ^(id obj, CGFloat values[]) {
- values[0] = [[obj description] floatValue];};
- prop.writeBlock = ^(id obj, const CGFloat values[]) {
- [obj setText:[NSString stringWithFormat:@"%.2f",values[0]]];};
- prop.threshold = 0.01;}];
- anim.property = prop;
- anim.fromValue = @(0.0);
- anim.toValue = @(100.0);
- case UIGestureRecognizerStateChanged: {
- [self.popCircle.layer pop_removeAllAnimations];
- CGPoint translation = [pan translationInView:self.view];
- CGPoint center = self.popCircle.center;
- center.x += translation.x;
- center.y += translation.y;
- self.popCircle.center = center;
- [pan setTranslation:CGPointZero inView:self.popCircle];
- break;
- }
- case UIGestureRecognizerStateEnded:
- case UIGestureRecognizerStateCancelled: {
- CGPoint velocity = [pan velocityInView:self.view];
- [self addDecayPositionAnimationWithVelocity:velocity];
- break;
- }
- POPDecayAnimation *anim = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerPosition];
- anim.velocity = [NSValue valueWithCGPoint:CGPointMake(velocity.x, velocity.y)];

- POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
- anim.fromValue = @-200;
- anim.toValue = @(self.view.center.y);
- POPBasicAnimation *opacityAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity];
- opacityAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- opacityAnim.toValue = @1.0;
- POPBasicAnimation *rotationAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerRotation];
- rotationAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- rotationAnim.beginTime = CACurrentMediaTime() + 0.1;
- rotationAnim.toValue = @(0);

- CAShapeLayer *progressLayer = [CAShapeLayer layer];
- progressLayer.strokeColor = [UIColor colorWithWhite:1.0 alpha:0.98].CGColor;
- progressLayer.lineWidth = 26.0;
- UIBezierPath *progressline = [UIBezierPath bezierPath];
- [progressline moveToPoint:CGPointMake(25.0, 25.0)];
- [progressline addLineToPoint:CGPointMake(700.0, 25.0)];
- progressLayer.path = progressline.CGPath;
- POPSpringAnimation *scaleAnim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
- scaleAnim.toValue = [NSValue valueWithCGPoint:CGPointMake(0.3, 0.3)];
- POPSpringAnimation *boundsAnim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerBounds];
- boundsAnim.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 800, 50)];
- boundsAnim.completionBlock = ^(POPAnimation *anim, BOOL finished) {
- if (finished) {
- UIGraphicsBeginImageContextWithOptions(self.popCircle.frame.size, NO, 0.0);
- POPBasicAnimation *progressBoundsAnim = [POPBasicAnimation animationWithPropertyNamed:kPOPShapeLayerStrokeEnd];
- progressBoundsAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- progressBoundsAnim.toValue = @1.0;
- progressBoundsAnim.completionBlock = ^(POPAnimation *anim, BOOL finished) {if (finished) {UIGraphicsEndImageContext();}};
- [progressLayer pop_addAnimation:progressBoundsAnim forKey:@"AnimateBounds"];
- }
- };
Facebook POP 进阶指南的更多相关文章
- Facebook POP 使用指南
Facebook POP 使用指南 Pop是一个动画引擎,用以扩展iOS.OSX的动画类型.相较于iOS.OSX中的基本动画效果,Pop扩展后支持弹簧动画效果与衰减动画效果,你可以用Pop动画引擎来构 ...
- iOS开发Facebook POP动效库使用教程
如果说Origami这款动效原型工具是Facebook Paper的幕后功臣,那么POP便是Origami的地基.感谢Facebook开源了POP动效库,让人人都能制作出华丽的动效.我们只需5步,便能 ...
- Facebook POP动效库使用教程
编者注:用Origami作iOS动效的同学如果愁怎么实现,可以把这个给开发看看作为参考哦 如果说Origami这款动效原型工具是Facebook Paper的幕后功臣,那么POP便是Origami的地 ...
- HTML5游戏开发进阶指南(亚马逊5星畅销书,教你用HTML5和JavaScript构建游戏!)
HTML5游戏开发进阶指南(亚马逊星畅销书,教你用HTML5和JavaScript构建游戏!) [印]香卡(Shankar,A.R.)著 谢光磊译 ISBN 978-7-121-21226-0 201 ...
- Weex入门与进阶指南
Weex入门与进阶指南 标签: WeexiOSNative 2016-07-08 18:22 59586人阅读 评论(8) 收藏 举报 本文章已收录于: iOS知识库 分类: iOS(87) 职 ...
- 【读书笔记】读《高性能网站建设指南》及《高性能网站建设进阶指南:Web开发者性能优化最佳实践》
这两本书就一块儿搞了,大多数已经理解,简单做个标记.主要对自己不太了解的地方,做一些记录. 一.读<高性能网站建设指南> 0> 黄金性能法则:只有10%~20%的最终用户响应时间 ...
- 走进 Facebook POP 的世界
POP: 一个流行的可扩展的动画引擎iOS,它支持spring和衰变动态动画,使其可用于构建现实,基于物理交互.Objective - C API允许快速集成, 对于所有的动画和过渡他是成熟的. 解释 ...
- HTML5游戏开发进阶指南
<HTML5游戏开发进阶指南> 基本信息 作者: (印)香卡(Shankar,A.R.) 译者: 谢光磊 出版社:电子工业出版社 ISBN:9787121212260 上架时间:20 ...
- iOS进阶指南试读之UI篇
iOS进阶指南试读之UI篇 UI篇 UI是一个iOS开发工程师的基本功.怎么说?UI本质上就是你调用苹果提供给你的API来完成设计师的设计.所以,想提升UI的功力也很简单,没事就看看UIKit里的各个 ...
随机推荐
- 矩阵快速幂2 3*n铺方格
#include <iostream> #include <cstdlib> #include <cstring> #include <queue> # ...
- Spring注解驱动开发(四)-----aop、声明式事务
AOP 概念 指在程序运行期间动态的将某段代码切入到指定方法指定位置进行运行的编程方式:-----基于动态代理 一个aop示例 1.导入aop模块:Spring AOP:(spring-aspects ...
- JDBC2 --- 获取数据库连接的方式二 --- 技术搬运工(尚硅谷)
/** * 方式二,对方式一的迭代 * 在如下的程序中,不出现第三方的api,使得程序具有更好的可移植性. * @throws Exception */ @Test public void testC ...
- Linux中如何安装mysql数据库
安装mysql 1.解压源码压缩包 如果服务器可以上网也可以采用在线安装方式,在线安装操作简单具体见下面在线安装步骤 进入源码压缩包所在目录输入#tar -zxvf mysql-5.6.17-linu ...
- umask权限使用
很显然,系统中各种文件的权限设置对特定用户的数据安全有很大影响.但是要求用户逐一明确设置系统中每个文件的权限也是不现实的,为此,需要使用umask命令,该命令可以为用户账号中新文件的创建进行缺省设置. ...
- 02Redis入门指南笔记(基本数据类型)
一:热身 获得符合规则的健名列表:keys pattern pattern支持glob风格的通配符,具体规则如下表: Redis命令不区分大小写.keys命令需要遍历Redis中的所有健,当键的数量 ...
- bzoj 2935 [Poi1999]原始生物——欧拉回路思路!
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2935 有向图用最小的路径(==总点数最少)覆盖所有边. 完了完了我居然连1999年的题都做不 ...
- loj2322 「清华集训 2017」Hello world!
https://loj.ac/problem/2322 先吐槽一下,sb数据毁我青春败我前程. 首先,一个数开根开不了多少次. 当我们把它开到1的时候,我们以后就不需要开他了,我们可以利用并查集跳过他 ...
- h5文件简介
h5文件是层次格式的第5代版本,用于存储科学数据的一种文件格式和库文件,由美国超级计算中心与应用中心研发的文件格式,用以存储和组织大规模数据. H5将文件结构简化成两个主要的对象类型: 1 数据集da ...
- HDU3486 RMQ
/*多么变态的一道题,交了18次*/ #include<cstdio> #include<cstring> #include<cmath> #define max( ...