效果图:

#import "ViewController.h"
#import <POP.h> @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; // 初始化按钮
UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
btn.center = self.view.center;
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn]; // 初始化拖拽手势
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(btnPan:)];
[btn addGestureRecognizer:pan]; } - (void)btnPan:(UIPanGestureRecognizer *)recognizer
{
// 获取手指移动后的位置
CGPoint translation = [recognizer translationInView:self.view]; UIButton *btn = (UIButton *)recognizer.view;
btn.center = CGPointMake(btn.center.x + translation.x, btn.center.y + translation.y); // 复位, 否则手势会保留上一次的状态
[recognizer setTranslation:CGPointMake(, ) inView:self.view]; if (recognizer.state == UIGestureRecognizerStateEnded) { // 手势结束
// 初始化POP的衰减动画
POPDecayAnimation *decay = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerPosition];
// 设置加速度值
decay.velocity = [NSValue valueWithCGPoint:[recognizer velocityInView:self.view]];
// 添加动画
[btn.layer pop_addAnimation:decay forKey:nil];
}
} // 点击按钮时移除所有POP动画
- (void)btnClick:(UIButton *)btn
{
[btn.layer pop_removeAllAnimations];
} @end

github:https://github.com/RinpeChen/POPDecayAnimationDemo

用POP动画引擎实现衰减动画(POPDecayAnimation)的更多相关文章

  1. 用POP动画引擎实现弹簧动画(POPSpringAnimation)

    效果图: #import "ViewController.h" #import <POP.h> @interface ViewController () @proper ...

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

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

  3. [译]理解 Windows UI 动画引擎

    本文译自 Nick Waggoner 的 "Understand what’s possible with the Windows UI Animation Engine",已获原 ...

  4. 聊聊动画引擎 pop

    iOS可以通过CADisplayLink实现自定义动画引擎,pop就是基于此实现的,而且比原生Core Animation更强大好用.譬如当ViewController侧滑返回的时候,系统会将Core ...

  5. POP动画引擎中Layer与CALayer的一点区别

    POP动画引擎是facebook提供的一个开源框架, 可以实现很多的动画效果, 这里就不一一介绍啦, 有兴趣的童鞋请移步: https://github.com/facebook/pop 下面简单的讲 ...

  6. SpriteSheet精灵动画引擎

    SpriteSheet精灵动画引擎   本文介绍Flash中SpriteSheet精灵序列图与其它渲染方式的性能对比.SpriteSheet的原理及注意实现,最后实现了一个精灵序列图的渲染引擎.本文的 ...

  7. Unity3d动画脚本 Animation Scripting(深入了解游戏引擎中的动画处理原理)

    也许这一篇文章的内容有点枯燥,但我要说的是如果你想深入的了解游戏引擎是如何处理动画片断或者素材并 让玩家操控的角色动起来栩栩如生,那么这真是一篇好文章(当然我仅仅是翻译了一下)   动画脚本 Anim ...

  8. 第四十二课:基于CSS的动画引擎

    由于低版本浏览器不支持css3 animation,因此我们需要根据浏览器来选择不同的动画引擎.如果浏览器支持css3 animation,那么就使用此动画引擎,如果不支持,就使用javascript ...

  9. iOS_SN_push/pop转场动画封装和一般动画封装

    封装类中的方法: #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface AnimationE ...

随机推荐

  1. DOM&BOM笔记

    day01正课:1. DOM概述2. ***DOM树3. *查找 1. DOM概述: DHTML:动态网页技术的统称 DHTML=HTML+CSS+JS 鄙视题: HTML XHTML DHTML X ...

  2. cf D. Maximum Submatrix 2

    http://codeforces.com/contest/376/problem/D 题意:给你一个矩阵,可以随意排列n行的次序,然后找出全部含有1的子矩阵.输出1的个数. 思路:c[i][j]表示 ...

  3. Chapter 6 — Improving ASP.NET Performance

    https://msdn.microsoft.com/en-us/library/ff647787.aspx Retired Content This content is outdated and ...

  4. Power Network (最大流增广路算法模板题)

    Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 20754   Accepted: 10872 Description A p ...

  5. POJ2513 Colored Sticks(欧拉)

    题目链接. 题目大意: 给很多木棍,两端被涂了颜色.任意两根木棍的相同颜色处可以拼接在一起,问有没有可能将所有的木棍都连起来,成一条直线? 分析: 考点,欧拉道路. 将一根木棍看成一条边,两端的颜色看 ...

  6. POJ1321 棋盘问题(dfs)

    题目链接. 分析: 用 dfs 一行一行的搜索,col记录当前列是否已经放置. AC代码如下: #include <iostream> #include <cstdio> #i ...

  7. -_-#ueditor编辑器chrome浏览器下只能复制最后一行

    被过滤掉了

  8. 调试makefile—subst函数

    操作系统:ubuntu10.04 Makefile里的subst用法是$(subst FROM,TO,TEXT),即将TEXT中的东西从FROM变为TO Makefile中的字符串处理函数格式:    ...

  9. js到记时代码

    原文地址:http://www.w3school.com.cn/tiy/t.asp?f=hdom_timing_infinite html><head><script type ...

  10. Class Prefix(Xcode6以后设置类前缀)

    点开Xcode右侧Utilities,Project Document->Class Prefix  图片:prefix.png