实例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. C# 线程系列三 定时器线程

    上一篇文章我们讲诉了自定义线程执行器和任务处理器 我们继续来讲解自定义线程的定时执行器,我们在很多场景下需要做到某些状态或者数据进行更新,如果事情很多很杂,很时候时候会创建很多不同的定时器那么势必会照 ...

  2. 微软官方网站线上兼容测试平台-Browser screenshots

    前端开发时最不想做的就是在不同浏览器.平台和分辨率测试网页显示效果,通常这会浮现许多问题,尤其浏览器版本就可能让显示成效完全不同,也只好尽力维持让每一种设备都能正常浏览网页.修改到完全没有问题必须投入 ...

  3. Android开发中遇到的requestFeature() must be called before adding content异常

    缘起 上一篇博文中讲到了几种实现全屏显示Activity内容的方法.然而实际在实现中发现了一些问题,在本篇博文中进行总结下.首先交代一下开发环境,本人使用的是Android Studio 1.5.1, ...

  4. Winform 显示Gif图片

    代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data ...

  5. VS10x CodeMap 注册码 key VS插件CodeMap

    VS10x CodeMap 注册码(key): #$aCN/L/ra73OaqCJENXc2JIDL61IMawNWBBX+PxhBzobE9w3QlcrwoXeB3DWBC2f56y9r0Hx2XP ...

  6. WCF双工通讯以及客户端间的间接通讯

    由于学习计划安排不当,对WCF的认知一直停滞不前,最近工作上又用回了WCF,重拾一下,看到蒋老师介绍双工通讯的博文,实践一下,积累一下.原想着WCF的双工通讯就是原本的客户端能调用服务端的方法之余,服 ...

  7. 提升VMware虚拟机性能招数

    在VMware虚拟机(VMware Workstation或VMware Server)中我们可以同时运行多个Guest OS,当同时在同一Host OS中运行多台虚拟机时势必会严重影响到Host O ...

  8. jvm运行数据分布

    本人看的深入理解jvm(该版本的java se7) java运行时数据区域 Java虚拟机在执行java程序时,把内存划分为几个不同的阶段,存在不同的存在时间.不同的用途 先上图 程序计数器:是jvm ...

  9. 【转】MyEclipse 2015优化技巧

    MyEclipse 2015优化技巧 MyEclipse 2015优化速度方案仍然主要有这么几个方面:去除无需加载的模块.取消冗余的配置.去除不必要的检查.关闭更新. 第一步: 去除不需要加载的模块 ...

  10. java集合-集合大家族

    在编写 Java 程序中,我们最常用的除了八种基本数据类型,String 对象外还有一个集合类,在我们的的程序中到处充斥着集合类的身影!Java 中集合大家族的成员实在是太丰富了,有常用的 Array ...