FaceBook pop 动画开源框架使用教程说明
https://github.com/facebook/pop

Pop is an extensible animation engine for iOS and OS X. In addition to basic static animations, it supports spring and decay dynamic animations, making it useful for building realistic, physics-based interactions. The API allows quick integration with existing Objective-C codebases and enables the animation of any property on any object. It's a mature and well-tested framework that drives all the animations and transitions in Paper.
POPdemo
A simple demo for facebook's pop framework.
pop一共有四个大类
POPSpringAnimation 有弹性效果的动画类(个人比较喜欢这个)
POPBasicAnimation 基本动画类
POPDecayAnimation 衰减动画类
POPCustomAnimation 可以自定义动画的类
导入pop
很简单,直接把pop文件夹拖到项目里,然后导入pop.h即可。
#import "POP.h"
下面的代码示例用POPSpringAnimation做一个弹性放大-缩小的效果
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib. //添加手势
UITapGestureRecognizer *gestureForSpring = [[UITapGestureRecognizer alloc] init];
[gestureForSpring addTarget:self action:@selector(changeSize:)];
[_springView addGestureRecognizer:gestureForSpring]; } - (void)changeSize:(UITapGestureRecognizer*)tap{
-
//用POPSpringAnimation 让viewBlue实现弹性放大缩小的效果
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerSize]; CGRect rect = _springView.frame;
if (rect.size.width==100) {
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(300, 300)];
}
else{
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(100, 100)];
} //弹性值
springAnimation.springBounciness = 20.0;
//弹性速度
springAnimation.springSpeed = 20.0; [_springView.layer pop_addAnimation:springAnimation forKey:@"changesize"]; }
效果如下

上面的代码是改变view的size,下面示例改变position
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPosition];
CGPoint point = _springView.center;
if (point.y==240) {
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(point.x, -230)];
}
else{
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(point.x, 240)];
}
//弹性值
springAnimation.springBounciness = 20.0;
//弹性速度
springAnimation.springSpeed = 20.0;
[_springView pop_addAnimation:springAnimation forKey:@"changeposition"];
效果:

这个效果可以做一个弹出框从上往下跳出来,我之前做过这个效果,用了N多代码,用pop只用几句代码就实现了。
一个比较实用的效果,弹出菜单:

代码如下:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"+" style:UIBarButtonItemStyleDone target:self action:@selector(showPop)];
- (void)showPop{
if (_isOpened) {
[self hidePop];
return;
}
_isOpened = YES;
POPSpringAnimation *positionAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
positionAnimation.fromValue = [NSValue valueWithCGRect:_hidePosition];
positionAnimation.toValue = [NSValue valueWithCGRect:_showPosition];
positionAnimation.springBounciness = 15.0f;
positionAnimation.springSpeed = 20.0f;
[_popView pop_addAnimation:positionAnimation forKey:@"frameAnimation"];
}
- (void)hidePop{
POPBasicAnimation *positionAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame];
positionAnimation.fromValue = [NSValue valueWithCGRect:_showPosition];
positionAnimation.toValue = [NSValue valueWithCGRect:_hidePosition];
//key一样就会用后面的动画覆盖之前的
[_popView pop_addAnimation:positionAnimation forKey:@"frameAnimation"];
_isOpened = NO;
}
FaceBook pop 动画开源框架使用教程说明的更多相关文章
- iOS开发Facebook POP动效库使用教程
如果说Origami这款动效原型工具是Facebook Paper的幕后功臣,那么POP便是Origami的地基.感谢Facebook开源了POP动效库,让人人都能制作出华丽的动效.我们只需5步,便能 ...
- Facebook POP动效库使用教程
编者注:用Origami作iOS动效的同学如果愁怎么实现,可以把这个给开发看看作为参考哦 如果说Origami这款动效原型工具是Facebook Paper的幕后功臣,那么POP便是Origami的地 ...
- [翻译] POP Facebook的动画开源库
Pop is an extensible animation engine for iOS and OS X. In addition to basic static animations, it s ...
- android gif动画开源框架android-gif-drawable
地址:https://github.com/koral--/android-gif-drawable github里介绍挺详细的 项目中需要显示gif图片,并对用户体验有较高的要求,之前一直在使用 ...
- iOS - 开源框架、项目和学习资料汇总(动画篇)
动画 1. Core Animation笔记,基本的使用方法 – Core Animation笔记,基本的使用方法:1.基本动画,2.多步动画,3.沿路径的动画,4.时间函数,5.动画组.2. awe ...
- Android绘图机制(四)——使用HelloCharts开源框架搭建一系列炫酷图表,柱形图,折线图,饼状图和动画特效,抽丝剥茧带你认识图表之美
Android绘图机制(四)--使用HelloCharts开源框架搭建一系列炫酷图表,柱形图,折线图,饼状图和动画特效,抽丝剥茧带你认识图表之美 这里为什么不继续把自定义View写下去呢,因为最近项目 ...
- Farseer.net轻量级ORM开源框架 V1.x 教程目录
本篇教程将以Ver 1.x版本进行详细使用讲解 大家有任何疑问可以加入我们的官方QQ群进行讨论.QQ群:116228666 (Farseer.net开源框架交流) 请注明:Farseer.Net 整个 ...
- facebook打开动画pop
POP源代码:https://github.com/facebook/pop demo相关链接:https://github.com/jxd001/POPdemo/blob/master/README ...
- iOS常用第三方开源框架和优秀开发者博客等
博客收藏iOS开发过程好的开源框架.开源项目.Xcode工具插件.Mac软件.文章等,会不断更新维护,希望对你们有帮助.如果有推荐或者建议,请到此处提交推荐或者联系我. 该文档已提交GitHub,点击 ...
随机推荐
- 1.11-1.12 Sqoop导入数据时两种增量方式导入及direct
一.增量数据的导入 1.两种方式 ## query 有一个唯一标识符,通常这个表都有一个字段,类似于插入时间createtime where createtime => 201509240000 ...
- crontab计划任务监控nginx服务器
#!/bin/bash ps axu |grep 'nginx' |grep -v 'grep' &>/dev/null ] then echo "准备重启nginx....& ...
- 20个Flutter实例视频教程-第14节: 展开闭合列表案例
博客地址; https://jspang.com/post/flutterDemo.html#toc-5b0 视频地址: https://www.bilibili.com/video/av397092 ...
- Mac中自定义文件夹中文名
在OSX系统中,我们打开finer,就会看到很多中文名的文件夹,比如“应用程序”.“桌面”等等,而在系统中都是以英文命名的.我们也可以自己去设置中文名. 首先需要找到设置中文的字符串资源文件,路径是/ ...
- 658. Find K Closest Elements
Given a sorted array, two integers k and x, find the k closest elements to x in the array. The resul ...
- profiler Reserved Total
Used Total和Reserved 均是物理内存,其中Reserved是unity向系统申请的总内存,Unity底层为了不经常向系统申请开辟内存,开启了较大一块内存作为缓存,即所谓的Reserve ...
- 洛谷P3265 [JLOI2015]装备购买(线性基+高斯消元)
传送门 不知道线性基是什么东西的可以看看蒟蒻的总结 不难看出题目讲的就是线性基 这种最小化权值的问题一般都是贪心的,就是按价值从低到高考虑每一个是否能选 据说贪心的证明得用拟阵我不会 据说这题是实数意 ...
- 51 Nod 1640 天气晴朗的魔法( Kruskall )
#include <bits/stdc++.h> typedef long long LL; using namespace std; ; struct node{ LL u,v,w; n ...
- A - Beautiful numbers
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> ...
- Hexo搭建博客教程(2) - 博客的简单个性化配置
本章主要讲博客的个性化,譬如站点的基本配置(语言.头像.站点图标等).安装新的Hexo主题(NexT主题)以及主题的配置. 1. 修改站点配置 打开站点配置文件 ,找到: # Site title: ...