Motion Design for IOS (41)

Source: Internet
Author: User

Just like jnwspringanimation, you can adjust the properties of the spring action you want to imitate. Here is the relevant part of the previous example.

scale20.0// Between 0-20scale1.0// Between 0-20

Pop allows you to adjust the spring's elasticity and speed. Each value can be from 0 to 20. Just like block-based spring animations in iOS 7, these values are an abstraction of the true value of the spring action equation. And unlike iOS 7, I think pop does a great job of abstracting these values, and I've never used pop to create a spring action that looks unnatural or violates physical laws.

If you want to adjust the actual values used by the action equations, you can also drill down to a deeper level to manipulate them.

scale.dynamicsFriction20;scale.dynamicsMass1;scale.dynamicsTension300;

These values are similar to the values used in jnwspringanimation, but not exactly the same, so if you want to make an exact jnwspringanimation into a pop, you need to tweak it. Fortunately, the springbounciness and springspeed values have done a good job of controlling the springs, so I often use them directly.

Let's see how the adjustment of the elastic values will affect the animation.

The speed of the three balls is 10. The elasticity of the red ball is 5, the basketball is 12, the green ball is 20.

Finally, we add animations to the objects we want to animate.

forKey:@"scaleAnimation"];

We call the-pop_addanimation:forkey: method on the view and animate the object into the Pop_addanimation:, and then put "scale" into Forkey:. Unlike Jnwspringanimation and other core animation, the keys we pass in don't need to match the properties of our animations. This key is just a unique name for the animation on the view, which can be any value you want. If you want to get an animation when you run it, you can use this key to ask for a view or a layer's pop animation, which is what it does.

Now let's add some different animations at once, each animating different properties. Before we show the code, here's what it looks like.

This animation does four things: the size of the view pulls up, moves to the right, rotates, and changes the background color. This is the four separate animations we added, and there are four separate animated objects, each representing a different animation.

Popspringanimation *scale = [Popspringanimation animationwithpropertynamed:kpopviewscalexy];Scale. Tovalue= [Nsvalue Valuewithcgpoint:cgpointmake (1.5,1.5)];Scale. Springbounciness= the;Scale. Springspeed=5.0F;[Orangesquare Pop_addanimation:scale forkey:@"Scale"];Popspringanimation *move = [Popspringanimation Animationwithpropertynamed:kpoplayerpositionx];Move. Tovalue= @( -);Move. Springbounciness= the;Move. Springspeed=5.0F;[Orangesquare. LayerPop_addanimation:move forkey:@"Position"];Popspringanimation *spin = [Popspringanimation animationwithpropertynamed:kpoplayerrotation];Spin. Tovalue= @ (m_pi*4);Spin. Springbounciness= the;Spin. Springspeed=5.0F;[Orangesquare. LayerPop_addanimation:spin forkey:@"Spin"];Popspringanimation *color = [Popspringanimation Animationwithpropertynamed:kpopviewbackgroundcolor];Color. Tovalue= [Uicolor Greencolor];Color. Springbounciness= the;Color. Springspeed=5.0F;[Orangesquare Pop_addanimation:color forkey:@"Colorchange"];

We used animations that manipulate the following properties: Kpopviewscalexy, Kpoplayerpositionx, Kpoplayerrotation, Kpopviewbackgroundcolor. Two animations when about a view, two animations are about layer.

If you look at the Tovalue variable that we set as the final value, we can see a few different ways to set it up. As I said before, Pop is a funny (and a little annoying?). The point is that the value that POPs expects Tovalue to change depends on the properties you want to animate. For stretching, we've already said that it wants an NSValue object. For the X position animation, we can simply use the Objective-c shortcut @ (500) to bring 500 to the object. For rotation, we also use the Special @ () syntax. We set an object for the color UIColor . So you can see that because pop supports too many animated properties, there are subtle differences that need to be understood. I used to confuse NSValue包装的 Cgpoint ' and stared at my code for 30 seconds before realizing it wanted some different values.

It's time to build some cool stuff out of pop.

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 (41)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.