JNWSpringAnimation

https://github.com/jwilling/JNWSpringAnimation

JNWSpringAnimation is a subclass of CAKeyframeAnimation that adds support for creating damped harmonic animations.

JNWSpringAnimation 是 CAKeyframeAnimation 的子类,它支持创建阻尼动画效果。

Getting Started

Although JNWSpringAnimation is a subclass of CAKeyframeAnimation, it should be treated as if it were a subclass of CABasicAnimation.

尽管,JNWSpringAnimation 是 CAKeyframeAnimation 的子类,但是,你应该把他当做 CABasicAnimation 的子类来使用:)。

To get started, copy the four source files into your project.

把4个源文件拷贝到你的工程当中。

The animation can be created by using the dedicated initializer, +animationWithKeyPath:. Alternatively, the animation can be created using +animation and by setting the key path afterwards. The full list of currently-compatible animatable properties is available in the header.

你可以使用专用的初始化方法 +animationWithKeyPath:。当然,你也可以使用 +animation 方法,之后再来设置 keyPath 。目前所有兼容的属性动画都包含在头文件当中。

JNWSpringAnimation *animation = [JNWSpringAnimation animationWithKeyPath:@"position.x"];

Next, the fromValue and toValue properties must be set for the interpolated values to be calculated correctly.

下一步,fromeValue 与 toValue 属性需要插入正确的值哦。

animation.toValue = @(toX);
animation.fromValue = @(currentX);

Finally, the values for the spring constants can optionally be changed. Currently, stiffnessdamping, andmass are available for modification.

最后,阻尼动画的一些参数也可以修改,目前包括 stiffness(生硬程度),damping(衰弱程度?)以及mass(质量)。

animation.mass = 30; // this will move extremely slowly
// and so on

The animation itself can be applied like any other subclass of CAAnimation, namely -addAnimation:forKey: on any CALayer.

这个动画本身可以被任何CAAnimation的子类接收,你可以将他添加到CALayer中。

What's this for?

This was created in my desire to have an open-source version of the (currently private) CASpringAnimationwhich was discovered in iOS 6.

Spring animations, when used appropriately, can really enhance the way your app feels to the user by connecting in physical simulations with an app's interface. And besides, who doesn't love messing around with springs?

What's left to do?

I created this as a weekend project, so the implementation is still somewhat unfinished. Compared toCASpringAnimation, the velocity property is still unimplemented. Pull requests are welcome.

这只是我的小项目中的一部分,所以有些东西还不完善。

[翻译] JNWSpringAnimation的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. 基于Flume做FTP文件实时同步的windows服务。

    需求:做一个windows服务,实现从ftp服务器实时下载或者更新文件到本地磁盘. 功能挺简单的.直接写个ftp工具类用定时器跑就能搞定,那我为什么不用呢? 别问,问就是我无聊啊,然后研究一下Flum ...

  2. 解决Linux下pcieport 0000:00:1c.5问题导致的系统根目录/磁盘空间不足

    最近刚换了笔记本,拿到本后在win10基础装上Ubuntu 16.04双系统,有个问题是每次关机都会报一堆pcie问题,并且经常没声音,声音问题通过上一篇文章暂时解决,然后就没在意了,可是几天后出现系 ...

  3. PHP之string

    string addcslashes() Quote string with slashes in a C style 以 C 语言风格使用反斜线转义字符串中的字符 addslashes() Quot ...

  4. 费了个劲的git

    终于学会了git,表示不容易,个人表示总结一下... 1.设置个人PC上的git  master路径,ok没问题,用时1min 2.从码云代码仓库克隆已写代码,也很简单,用时2min 3.将本机器内文 ...

  5. ajax从零基础到实战

    一. 什么是AJAX? ajax是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术. 二. 在项目中怎么运用AJAX? 项目主要文件夹目录有img文件夹,css文件夹,js文件夹,如果你要运 ...

  6. android studio全局搜索关键字

  7. [译]用R语言做挖掘数据《二》

    数据探索 一.实验说明 1. 环境登录 无需密码自动登录,系统用户名shiyanlou,密码shiyanlou 2. 环境介绍 本实验环境采用带桌面的Ubuntu Linux环境,实验中会用到程序: ...

  8. [转]从客户端中检测到有潜在危险的Request.Form值的详细解决

    本文转自:http://www.knowsky.com/887593.html asp.net1.1后引入了对提交表单自动检查是否存在XSS(跨站脚本攻击)的能力.当用户试图用之类的输入影响页面返回结 ...

  9. 微信WeUI入门2

    引入需要的样式文件 最重要的css文件为 weui.min.css 基本的框架如下: <!DOCTYPE html> <html lang="zh-CN"> ...

  10. CF898A Rounding

    题意翻译 给你一个数字,将其“四舍六入”,末尾为5舍去或进位都可,求最终的数字. 题目描述 Vasya has a non-negative integer n n n . He wants to r ...