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里的各个 ...
随机推荐
- Bash新技能
1. 输出数组全部元素 echo ${array_name[@]} 2. 输出数组长度 echo ${#array_name[@]} #获得数组长度 echo ${#string_name} #获得字 ...
- ie浏览器将网页转成pdf
今天同事让我帮他将网页转成pdf,学了一个.先推荐一个超图的数据库使用指南:http://support.supermap.com.cn/DataWarehouse/WebDocHelp/6.1.1/ ...
- linux管道和tee命令
ps -ef | grep docker 等价于 ps -ef &> >(grep docker) cat a.log | tee b.txt 等价于 cat a.log & ...
- C# 利用Newtonsoft.Json 序列化生成Json数据
现在需要将一些数据转化成json格式返回给调用者, 使用Newtonsoft.Json.DLL库来帮助我们序列化 举例: {"300033":{"MC":&qu ...
- PAT甲级——A1017 Queueing at Bank
Suppose a bank has K windows open for service. There is a yellow line in front of the windows which ...
- docker和宿主机之间复制文件
从主机复制到容器sudo docker cp host_path containerID:container_path 从容器复制到主机sudo docker cp containerID:conta ...
- Win3.2有人用过么
老牌子的操作系统. 了,有人用过么,我还在用,感觉挺不错的,哈哈哈哈哈. 1.0那一代,画面粗糙,几乎不能算GUI操作系统. 2.0,画面较1.0一代明显改善,可惜的是,手头没货. 3.0 ...
- PetaPoco 基础操作
//初始化数据库连接 var db=new PetaPoco.Database("connectionStringName"); //查询单个值 long count=db.Exe ...
- Go之路一
一.声明变量 var a int var b string var c []float32 var d func() bool var e struct{ x int } 第1行,声明一个整型类型的变 ...
- [转]深入理解定位父级offsetParent及偏移大小
偏移量(offset dimension)是javascript中的一个重要的概念.涉及到偏移量的主要是offsetLeft.offsetTop.offsetHeight.offsetWidth这四个 ...