实例1:图片视图跟着手在屏幕上的点改变大小

- (void)viewDidLoad
{
[super viewDidLoad];
//添加手势
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc] init];
[gesture addTarget:self action:@selector(changeSize:)];
[self.view addGestureRecognizer:gesture]; } - (void)changeSize:(UIPanGestureRecognizer*)tap{
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame]; CGPoint point = [tap locationInView:self.view];
springAnimation.toValue = [NSValue valueWithCGRect:CGRectMake(, , point.x, point.y)]; //弹性值
springAnimation.springBounciness = 20.0;
//弹性速度
springAnimation.springSpeed = 20.0;
[_springView pop_addAnimation:springAnimation forKey:@"changeframe"]; }

实例2:实现一个弹出收缩视图的效果,弹出来有弹性的效果,收缩有变小的效果

- (void)viewDidLoad
{
[super viewDidLoad]; _showPosition = CGRectMake(-, , , );
_hidePosition = CGRectMake(, , , ); _popView = [[UIImageView alloc] initWithFrame:_hidePosition];
_popView.image = [UIImage imageNamed:@"menu.png"];
[self.view addSubview:_popView]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"+" style:UIBarButtonItemStyleDone target:self action:@selector(showPop)]; //让屏幕从导航栏下开始算(0,0)
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
} - (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];
[_popView pop_addAnimation:positionAnimation forKey:@"frameAnimation"]; _isOpened = NO;
}

实例3:创建两个按键,增加两个动画效果,其中一个按键是动画改变大小,另外一个修改ViewFrame,只要定位好坐标跟大小可以做出很不错的动画

@interface ViewController ()

@property (nonatomic, retain) UIView *button;
@property (nonatomic, retain) UIView *popOut;
@property (readwrite, assign) BOOL timerRunning; @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad]; _popOut = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TimerPopOut"]];
[_popOut setFrame:CGRectMake(, , , )];
[self.view addSubview:_popOut]; _button = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TimerButton"]];
[_button setFrame:CGRectMake(, , , )];
[self.view addSubview:_button]; _timerRunning = NO; [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(demoAnimate:)]];
} - (void)demoAnimate:(UITapGestureRecognizer*)tap
{
_timerRunning = !_timerRunning; POPSpringAnimation *buttonAnimation = [POPSpringAnimation animation];
buttonAnimation.property = [POPAnimatableProperty propertyWithName:kPOPLayerSize];
if (_timerRunning) {
buttonAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(, )];
}
else {
buttonAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(, )];
}
buttonAnimation.springBounciness = 10.0;
buttonAnimation.springSpeed = 10.0;
[_button pop_addAnimation:buttonAnimation forKey:@"pop"]; POPSpringAnimation *popOutAnimation = [POPSpringAnimation animation];
popOutAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewFrame];
if (!_timerRunning) {
popOutAnimation.toValue = [NSValue valueWithCGRect:CGRectMake(, , , )];
}
else {
popOutAnimation.toValue = [NSValue valueWithCGRect:CGRectMake(, , , )];
}
popOutAnimation.velocity = [NSValue valueWithCGRect:CGRectMake(, , , -)];
popOutAnimation.springBounciness = 10.0;
popOutAnimation.springSpeed = 10.0;
[_popOut pop_addAnimation:popOutAnimation forKey:@"slide"];
}

Facebook开源动画库 POP-小实例的更多相关文章

  1. Facebook 开源动画库 pop

    官网:https://github.com/facebook/pop Demo: https://github.com/callmeed/pop-playground 一:pop的基本构成: POPP ...

  2. 使用 Facebook开源动画库 POP 实现真实衰减动画

    1. POP动画基于底层刷新原理.是基于CADisplayLink,1秒钟运行60秒,接近于游戏开发引擎 @interface ViewController () @property (nonatom ...

  3. Facebook开源动画库 POP-POPBasicAnimation运用

    动画在APP开发过程中还是经常出现,将花几天的时间对Facebook开源动画库 POP进行简单的学习:本文主要针对的是POPBasicAnimation运用:实例源代码已经上传至gitHub,地址:h ...

  4. Facebook开源动画库 POP-POPDecayAnimation运用

    关于POPDecayAnimation的介绍先引用别人写的一些内容,基本上把它的一些注意点都说明了: Decay Animation 就是 POP 提供的另外一个非常特别的动画,他实现了一个衰减的效果 ...

  5. Facebook开源动画库 POP-POPSpringAnimation运用

    POPSpringAnimation也许是大多数人使用POP的理由 其提供一个类似弹簧一般的动画效果:实例源代码已经上传至gitHub,地址:https://github.com/wujunyang/ ...

  6. 第三方开源动画库EasyAnimation中一个小bug的修复

    看过iOS动画之旅的都知道,其中在最后提到一个作者写的开源动画库EasyAnimation(以下简称EA). EA对CoreAnimation中的view和layer动画做了更高层次的包装和抽象,使得 ...

  7. rebound是facebook的开源动画库

    网址:http://www.jcodecraeer.com/a/opensource/2015/0121/2338.html 介绍: rebound是facebook的开源动画库.可以认为这个动画库是 ...

  8. [转] iOS 动画库 Pop 和 Canvas 各自的优势和劣势是什么?

    iOS 动画库 Pop 和 Canvas 各自的优势和劣势是什么? http://www.zhihu.com/question/23654895/answer/25541037 拿 Canvas 来和 ...

  9. Lottie安卓开源动画库使用

    碉堡的Lottie Airbnb最近开源了一个名叫Lottie的动画库,它能够同时支持iOS,Android与ReactNative的开发.此消息一出,还在苦于探索自定义控件各种炫酷特效的我,兴奋地就 ...

随机推荐

  1. elasticsearch 查询(match和term)

    elasticsearch 查询(match和term) es中的查询请求有两种方式,一种是简易版的查询,另外一种是使用JSON完整的请求体,叫做结构化查询(DSL). 由于DSL查询更为直观也更为简 ...

  2. Python语言特性之4:类变量和实例变量

    类变量就是供类使用的变量,实例变量就是供实例使用的.如下面的代码: class Person: name = "Tacey" p1 = Person() p2 = Person() ...

  3. java继承的对象中构造函数的调用顺序

    建立两个继承关系的对象 public class Machine { public String machieNameString; public Machine() { System.out.pri ...

  4. Net重温之路一

    简述: 最简单的 Hello World 准备: 工具:VS2013 + SqlServer 2008 R2 我们将以.NET Framework 4.5 为基准 开始: 一:新建解决方案 > ...

  5. 不可或缺 Windows Native (17) - C++: 类与对象

    [源码下载] 不可或缺 Windows Native (17) - C++: 类与对象 作者:webabcd 介绍不可或缺 Windows Native 之 C++ 类与对象 示例1.类的设计CppE ...

  6. Windows下查看JDK是否安装以及安装路径

    查看JDK是否已经安装,可以在cmd窗口里输入java -version,如果没有提示出错,就表示已经安装. 查看JDK的安装路径,可以输入java -verbose,会返回很多信息,其中就包含了JD ...

  7. 【Java每日一题】20161031

    package Oct2016; import java.util.SortedSet; import java.util.TreeSet; public class Ques1031 { publi ...

  8. SNAT,是源地址转换,其作用是将ip数据包的源地址转换成另外一个地址

    SNAT,可能有人觉得奇怪,好好的为什么要进行ip地址转换啊,为了弄懂这个问题,我们要看一下局域网用户上公网的原理,假设内网主机A(192.168.2.8)要和外网主机B(61.132.62.131) ...

  9. 2016年湖南省第十二届大学生计算机程序设计竞赛---Parenthesis(线段树求区间最值)

    原题链接 http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 Description Bobo has a balanced parenthes ...

  10. Java集合源码分析(三)LinkedList

    LinkedList简介 LinkedList是基于双向循环链表(从源码中可以很容易看出)实现的,除了可以当做链表来操作外,它还可以当做栈.队列和双端队列来使用. LinkedList同样是非线程安全 ...