实例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. 浏览器退出之后php还会继续执行么?

    浏览器退出之后php还会继续执行么? 前提:这里说的是典型的lnmp结构,nginx+php-fpm的模式 如果我有个php程序执行地非常慢,甚至于在代码中sleep(),然后浏览器连接上服务的时候, ...

  2. 高性能Web系统设计方案(初稿目录),支持者进

    第一部分 客户端篇 1.压缩js.css,将js的引入放在</html>之前; 2.合并一个页面下的js/css文件,压缩传输.(SquishIt) 相关博文 3.ajax技术应用.aja ...

  3. 简述ES5 ES6

    很久前的某一天,一位大神问我,你知道ES6相对于ES5有什么改进吗? 我一脸懵逼的反问,那个啥,啥是ES5.ES6啊. 不得不承认与大神之间的差距,回来深思了这个问题,结合以前的知识,算是有了点眉目. ...

  4. C#基础整理参数

    基本概念 把数据传入方法中,可以使方法有多个返回值. 参数的传递 值参数,通过将实参的值复制到形参的方式传递数据.值参数的实参可以是变量或者是表达式

  5. ASP.NET MVC在线预览Excel、Word、TXT、PDF文件

    代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...

  6. C#进行Visio二次开发之文件导出及另存Web页面

    在我前面很多关于Visio的开发过程中,介绍了各种Visio的C#开发应用场景,包括对Visio的文档.模具文档.形状.属性数据.各种事件等相关的基础处理,以及Visio本身的整体项目应用,虽然时间过 ...

  7. 利用chrome调试JavaScript代码

    看见网上很多人问怎么用chrome调试JavaScript代码,我也对这个问题抱着疑问,但是没有找到一篇能用的中文文章(可能我的google有问题),也不知道怎么点出一篇E文的,感觉作者写得不错,所以 ...

  8. 初识Oracle数据库的基本操作

    SQL> --切换用户 SQL> connect practice/ 已连接. SQL> --查询学生表信息 SQL> select * from stuInfo; STUNO ...

  9. c#重点[封装,继承,多肽]

    面向对象的语言三大特点:封装.继承.多态 Ⅰ.封装:是把类的内部隐藏起来,以防止外部世界看见的一个面向对象的概念,通过关键字去控制变量,方法的访问权限. 1).访问修饰符: Ⅱ.继承: eg:我们建一 ...

  10. Android使用SQLite数据库(1)

    Android中使用SQLite数据库要通过SQLiteOpenHelper类. 首先,定义相关变量: // 数据库变量 DatabaseHelper mDBH; SQLiteDatabase db; ...