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.

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

最新文章

  1. .net基本数据类型操作
  2. 第三章Struts2 Action中动态方法调用、通配符的使用
  3. 查看Eclipse版本
  4. java 中遍历hashmap 和hashset 的方法
  5. ecstore小记
  6. BZOJ3223——Tyvj 1729 文艺平衡树
  7. LeetCode Flatten 2D Vector
  8. 【C#】【MySQL】C# 查询数据库语句@Row:=@Row+1
  9. java获取本月开始时间和结束时间、上个月第一天和最后一天的时间以及当前日期往前推一周、一个月
  10. PL/SQL Developer自动补全SQL技巧
  11. ORACLE【1】:触发器详解
  12. Xcode快捷键、小技巧与xib圆角设置
  13. UIBezierPath
  14. MBTI性格自测
  15. Entity Framework mvc Code First data migration
  16. php中curl的使用(一)
  17. Android热补丁技术—dexposed原理简析(手机淘宝采用方案)
  18. js判断设备是否为安卓
  19. JS 引用类型之Object
  20. Linux - PS1

热门文章

  1. jni使用javap查看java类方法签名
  2. ubuntu编译安装protobuf
  3. android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
  4. Oracle 汉字转拼音触发器
  5. C#的托管和非托管的简单理解
  6. 数据库SQLITE3初识
  7. js中json对象数组按对象属性排序
  8. 第7章 Scrapy突破反爬虫的限制
  9. GroupBox 分组框控件
  10. 01.CLR的执行模型