效果图:

#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. iOS开发——OC篇&纯代码退出键盘

    关于iOS开发中键盘的退出,其实方法有很多中,而且笔者也也学会了不少,包括各种非纯代码界面的退出. 但是最近开始着手项目的时候却闷了,因为太多了,笔者确实知道有很多中方法能实现,而且令我影响最深的就是 ...

  2. TCP回射服务器程序:str_echo函数

    str_echo函数执行处理每个客户的服务: 从客户读入数据,并把它们回射给客户 读入缓冲区并回射其中内容: read函数从套接字读入数据,writen函数把其中内容回射给客户 如果客户关闭连接,那么 ...

  3. Glide制作圆形图片

    上效果图: 第一步: AndroidStudio添加依赖库: compile 'com.github.bumptech.glide:glide:3.5.2' 第二步: <ImageView an ...

  4. python3.4.2 安装Pillow

    Python 3.x 安装Pillow给Python安装Pillow非常简单,使用pip或easy_install只要一行代码即可.在命令行使用PIP安装: pip install Pillow或在命 ...

  5. Android 之 WebView

    1:在AndroidManifest.xml中添加允许android访问网络权限. <uses-permission android:name="android.permission. ...

  6. Delphi 托盘程序实现 转

    unit MainUnit; interface uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, F ...

  7. 【日语】アップデート(update)一吻定情OP

    ねぇ~気づいてる? nee ~ kizu iteru ?呐~注意到吗? 私はアップデートしているよwatashi ha appude^to shiteiruyo我期待更新 いつか届きますようにitsu ...

  8. Oracle执行计划——all_rows和first_rows(n) 优化器模式

    0. 环境创建 SQL> create usertest identified by test 2 default tablespace users 3 temporary tablespace ...

  9. Android学习之电话拨号器

    本人自己是做android驱动的,也会接触到系统层.上层的应用,所以在闲暇的时候也就开始了学习android应用的路程,在这里把这些东西记下来,希望自己能坚持下去,也好以后复习用. 今天先实现一个简单 ...

  10. NGUI 动态字体边缘模糊,毛边的问题解决办法

    NGUI支持生成动态字体,将ttf格式的字体文件拖入工程,用NGUIFontMaker制作即可,但是制作完之后会发现字体有毛边,边缘模糊. 这时选中你生成的字体预设,在该预设的UIFont脚本上更改P ...