Let's look at some examples of animations that use jnwspringanimation to use different types of spring motions and have different properties. In our first example, we still want to animate the same red ball before, using our defined spring-managed spring effect to increase its size from 1 to twice times.
*scale = [JNWSpringAnimation animationWithKeyPath:@"transform.scale"];
First, we define our JNWSpringAnimation
object, a new instance of the animation, named scale. We use the defined initializer and set the critical path to "Transform.scale", but what does that mean? This critical path refers to the property or value that we want to animate. It is a property of the object under the view, which is the CALayer
animation we actually intend to animate with the keyframe. Remember the CALayer
real main force in core animation? This is because when you use animations like Keyframe animations, you place them on the layer you want to animate, and generally this layer is UIView
part of the object. Want to animate a photo show UIImageView
? Animate its layer. Want to animate one UIButton
? Animate its layer.
Based on this we have an object that knows what properties it is going to function on JNWSpringAnimation
. It is time to adjust the motion of the animation by adjusting the properties of some springs.
JNWSpringAnimation *scale = [JNWSpringAnimation animationWithKeyPath:@"transform.scale"];scale.damping9;scale.stiffness100;scale.mass2;
Damping, stiffness and mass are the three important spring properties we want to adjust to get the perfect action of our ball animations. How do I touch these values? Very simple! Jnwspringanimation also includes a Mac app that allows you to handle these three values interactively and see the results directly.
Another important point to note is that you did not set the duration in the jnwspringanimation like before in block-based UIView
animations. Damping, stiffness, and mass three properties or a spring action that results in the final value being settled once the system's mechanics reaches the final value. If you want to shorten the duration of your animation, you need to adjust the properties of the spring to reach the final value faster, generally increasing the damping properties of the spring. By not manually manipulating the overall duration of the spring action, you can move as the animated object wants to manage its entire motion and duration in the natural world with the true spring. That's why the animations created by jnwspringanimation look very natural and interesting.
We just used a red ball as an animated example, the action of the spring is not the key, when we start to animate the actual interface elements with the actions defined in the next section, and what we want to achieve is the key. This is why an interactive spring-defined app like Jnwspringanimation provides is important, and it saves a lot of time when you create your animations.
Finished viewing the integration set: Https://github.com/Cloudox/Motion-Design-for-iOS
All rights reserved: Http://blog.csdn.net/cloudox_
Motion Design for IOS (20)