1. POP动画基于底层刷新原理。是基于CADisplayLink,1秒钟运行60秒,接近于游戏开发引擎

@interface ViewController ()

@property (nonatomic,strong)CADisplayLink *displayLink;

@property (nonatomic)      NSInteger     count;

@end

- (void)viewDidLoad {

[superviewDidLoad];

self.displayLink = [CADisplayLinkdisplay LinkWithTarget:self

selector:@selector(displayLinkEvent:)];

[self performSelector:@selector(eventOne)

withObject:nil

afterDelay:];

[self performSelector:@selector(eventTwo)

withObject:nil

afterDelay:];

}

- (void)displayLinkEvent:(id)obj

{

self.count ++;

NSLog(@"count = %ld",(long)self.count);

}

- (void)eventOne{

[self.displayLink addToRunLoop:[NSRunLoopcurrentRunLoop]forMode:NSDefaultRunLoopMode];

}

- (void)eventTwo{

[self.displayLink invalidate];

}

二、POP动画引擎中 Layer与
CALayer的联系与差别

1.使用pop动画与使用CALayer动画很相似

2.POP动画的运行没有中间状态

3.POP动画是对CALayer的动画的扩充,但不能实现全部的CALayer的动画效果

4.POP动画能够作用在不论什么对象上,不不过CALayer

- (void)accessNormalLayer{

self.normalLayer = [CALayerlayer];

,,,);

self.normalLayer.backgroundColor = [UIColorredColor].CGColor;

[self.view.layeraddSublayer:self.normalLayer];

//

CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"position"];

basicAnimation.fromValue    = [NSValue valueWithCGPoint:self.normalLayer.position];

basicAnimation.toValue      = [NSValue valueWithCGPoint:CGPointMake( +,)];

basicAnimation.duration     = 4.0;

basicAnimation.timingFunction = \

[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

// layer的postion相当于view的center

+,);

[self.normalLayer addAnimation:basicAnimationforKey:nil];

//1.4秒移除后,动画直接到终点

[self performSelector:@selector(remoVeNormalAnimation)withObject:nilafterDelay:1.4];

}

- (void)remoVeNormalAnimation{

CALayer *layer = self.normalLayer.presentationLayer;

NSLog(@"%@",NSStringFromCGRect(layer.frame));

NSLog(@"%@",NSStringFromCGRect(self.normalLayer.frame));

[self.normalLayer removeAllAnimations];

}

三、用 POP动画引擎实现衰减动画

1.衰减动画由POPDecayAnimaiton来实现

2.须要精确计算停止运动瞬间的加速度才干用衰减动画做出真实的效果

- (void)handlePanGesture:(UIPanGestureRecognizer *)recognizer{

//获取定位点

CGPoint translation = [recognizer translationInView:self.view];

//recognizer.view.center
指的是button

recognizer.view.center =CGPointMake(recognizer.view.center.x + translation.x,

recognizer.view.center.y +translation.y);

//让他恢复坐标系

[recognizer setTranslation:CGPointMake(,)inView:self.view];

if (recognizer.state ==UIGestureRecognizerStateChanged) {

NSLog(@"手势停止时运行这一句话");

//获取加速度

CGPoint velocity = [recognizer velocityInView:self.view];

//初始化POP的deacy(衰减)动画

POPDecayAnimaton *decayAnimation = \

[POPDecayAnimation animationWithPropertyName:kPOPLayerPosition];

decayAnimation.velocity = [NSValue valueWithCGPoint:velocity];

[recognizer.view.layer pop_addAnimation:decayAnimation forKey:nil];

}

}

- (void)buttonEvent:(UIButton *)button

{

//[button.layer pop_removeAllAnimations];

}

- (void)viewDidLoad {

[superviewDidLoad];

,,,)];

self.button .backgroundColor = [UIColorredColor];

;

self.button.layer.masksToBounds =YES;

self.button.center =self.view.center;

[self.viewaddSubview:self.button];

[self.buttonaddTarget:self

action:@selector(buttonEvent:)

forControlEvents:UIControlEventTouchDragInside];

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizeralloc]initWithTarget:selfaction:@selector(handlePanGesture:)];

[self.buttonaddGestureRecognizer:panGesture];

Facebook官方的pop动画:附链接https://github.com/schneiderandre/popping

使用 Facebook开源动画库 POP 实现真实衰减动画的更多相关文章

  1. Facebook 开源动画库 pop

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

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

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

  3. Facebook开源动画库 POP-小实例

    实例1:图片视图跟着手在屏幕上的点改变大小 - (void)viewDidLoad { [super viewDidLoad]; //添加手势 UIPanGestureRecognizer *gest ...

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

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

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

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

  6. rebound是facebook的开源动画库

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

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

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

  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. 文件IO流总结

    文件在网络上或不同设备之间是怎么传输的,在Java程序中又是怎么来实现文件的传输,带着这两个问题,来了解一下Java中的IO流相关类及操作. 一.什么是流及流的用途 流是一组有顺序,有起点和终点的字节 ...

  2. PostgreSQL Replication之第二章 理解PostgreSQL的事务日志(4)

    2.4 调整检查点和XLOG 目前为止,这一章已经提供深入洞察PostgreSQL如何写入数据,一般来说,XLOG是用来干什么的.考虑到这方面的知识,我们现在可以继续并学习我们能做些什么来使我们的数据 ...

  3. 不同框架实现的todomvc

    http://todomvc.com/ http://hao.jobbole.com/

  4. zookeeper启动闪退

    编辑zkServer.cmd在它的尾行加上 pause      就可以将闪退停住来观察闪退的原因. 遇到Exception in thread "main" java.lang. ...

  5. 关于PHPExcel上传Excel单元格富文本和时间类型读取数据问题

    当用PHPExcel做Excel上传文件读取数据时,print_r出来的数据,竟然发现其中有几个单元格返回的是PHPExcel富文本对象,而且时间类型的单元格返回的是一个不是时间戳的五位数.就像下图那 ...

  6. 华为nova 4取代刘海屏

    尽管首发被三星“截胡”,但华为依然是第一批发布“打孔屏”新机的厂商.官方已经确认,将于12月17日在长沙发布华为nova 4,主打自拍极点全面屏. 继真机谍照.配置曝光之后,今日华为官方发布一则华为n ...

  7. caioj 1069 动态规划入门(二维一边推2:顺序对齐)(最长公共子序列拓展总结)

    caioj 1068是最长公共子序列裸体,秒过, 就不写博客了 caioj 1069到1071 都是最长公共字序列的拓展,我总结出了一个模型,屡试不爽    (1) 字符串下标从1开始,因为0用来表示 ...

  8. HDU 5373(2015多校7)-The shortest problem(模拟%11)

    题目地址:pid=5373">HDU 5373 题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n能否够被11整除. 思路:就是 ...

  9. easyui combobox 获取焦点

    easyui combobox 获取焦点 学习了:http://blog.csdn.net/foart/article/details/14446809 可以直接用: $('#spanZhudaoci ...

  10. [Python] Read and plot data from csv file

    Install: pip install pandas pip install matplotlib # check out the doc from site import pandas as pd ...