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里的各个 ...
随机推荐
- php filemtime filectime fileatime的区别
1.fileatime()int fileatime(string filename):fileatime()函数返回filename最后访问的时间,这里的最后访问是指每当一个文件的数据块被读取,采用 ...
- Python数据分析入门与实践
Python数据分析入门与实践 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大家看的时候可以关 ...
- 10 种最常见的 Javascript 错误(频率最高)
本文是小编给大家收藏的JavaScript 中频度最高的 10 种错误,我们会告诉你什么原因导致了这些错误,以及如何防止这些错误发生.写的十分的全面细致,具有一定的参考价值,对此有需要的朋友可以参考学 ...
- HBase底下的存储机制
Split机制:可以理解为HDFS上Block一分二的情况.每个Table一开始只有一个region,随着数据不断插入表,region不断增大,当增大到一个阀值的时候,Hregion就会等分会两个新的 ...
- Hadoop Serialization -- hadoop序列化详解 (2)【Text,BytesWritable,NullWritable】
回顾: 回顾序列化,其实原书的结构很清晰,我截图给出书中的章节结构: 序列化最主要的,最底层的是实现writable接口,wiritable规定读和写的游戏规则 (void write(DataOut ...
- file_instances文件实例表
SELECT * FROM performance_schema.file_instances;
- spring源码学习之容器的扩展(二)
六 BeanFactory的后处理BeanFactory作为spring容器的基础,用于存放所有已经加载的bean,为了保证程序上的高扩展性,spring针对BeanFactory做了大量的扩展,比如 ...
- 利用Qt自带工具发布程序
Qt官方开发环境生成的exe发布方式--使用windeployqt 从开始菜单-->Qt 5.4.0-->5.4-->MinGW 4.9 (32-bit)-->Qt 5.4 f ...
- Django项目:CRM(客户关系管理系统)--55--46PerfectCRM实现登陆后页面才能访问
#urls.py """PerfectCRM URL Configuration The `urlpatterns` list routes URLs to views. ...
- Ubuntu中安装gdal python版本
安装过程: python包是从C++包中编译出来的,所以需要将源码下载进行编译安装 1.GDAL中的矢量数据处理OGR依赖于Geos,在安装GDAL之前要安装Geos Geos的下载地址:http:/ ...