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. Java类文件结构及javac的ClassReader类解读

    首先来看一下ClassFile,类注释如下: A JVM class file. Generic Java classfiles have one additional attribute for c ...

  2. Linux下iptables 禁止端口和开放端口

    1.关闭所有的 INPUT FORWARD OUTPUT 只对某些端口开放.下面是命令实现: iptables -P INPUT DROP iptables -P FORWARD DROP iptab ...

  3. CSS动态控制DIV居中

    1.所谓的动态:就是即使手动去拖拉浏览器,DIV还是会自动居中 2.之前一直以为这个事情是JavaScript做的, 步骤:通过先获取页面的Height和Width, 然后定义DIV的Height和W ...

  4. AngularJS 的常用特性(三)

    6.表达式  在模板中使用表达式是为了以充分的灵活性在模板.业务逻辑和数据之间建立联系,同时又能避免让业务逻辑渗透到模板中. <div ng-controller="SomeContr ...

  5. 在Linux上创建webrev(cont)[基于svn]

    在前文中,基于git介绍了webrev工具.实际上,webrev工具还支持hg和svn.最近的工作中不可避免地要使用svn,故在此总结一下如何基于svn在Linux上创建webrev.顺便吐个槽,没有 ...

  6. 10 阻塞队列 & 生产者-消费者模式

    原文:http://www.cnblogs.com/dolphin0520/p/3932906.html 在前面我们接触的队列都是非阻塞队列,比如PriorityQueue.LinkedList(Li ...

  7. Linux文件夹打包发送到本地

    tar -cvf script.tar scriptsz script.tar 具体:  sz/rz命令:  一般来说,linux服务器大多是通过ssh来进行远程的登陆和管理的,如何在命令方式下上传和 ...

  8. [PY3]——字符串的分割、匹配、搜索方法总结

    ?分割.匹配.搜索时可以用到什么样的解决方法? 分割方法总结 1. str.split( ) * 分割字符串 * 返回列表 s1='I love python' # 默认以空格为界定符,且多个空格都当 ...

  9. 一句话讲清URI、URL、URN

    关于URI,URL ,URN URN(Uniform Resource Name):统一资源名称 URL(Uniform Resource Locator):统一资源定位符 URI(Uniform R ...

  10. HandlerInterceptor与MethodInterceptor

    HandlerInterceptor是springMVC项目中的拦截器,它拦截的目标是请求的地址,比MethodInterceptor先执行.实现一个HandlerInterceptor拦截器可以直接 ...