zoukankan      html  css  js  c++  java
  • [翻译] JNWSpringAnimation

    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.

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

  • 相关阅读:
    Stage划分原理
    Spark转换和动作算子
    Spark运行原理
    Scrapy数据持久化
    在实际工作中Eclipse常用的快捷键
    关于Linux(CentOS6.5)中文输入法、中文桌面可视化等问题
    Eclipse无法启动报An internal error occurred during: "reload maven project". java.lang.NullPointerExceptio错原因及解析
    在Eclipse中复制导入项目并且修改原来的项目名字,项目后面的括号显示原来项目的名字!
    response.sendRedirect()与request.getRequestDispatcher("/index.jsp").forward(request, response)两者辨析
    MyEclipse/Eclipse导出jar方法
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/3750085.html
Copyright © 2011-2022 走看看