[Go] IOS Animation Library What are the advantages and disadvantages of Pop and Canvas?

Source: Internet
Author: User

What are the advantages and disadvantages of the IOS animation library Pop and Canvas?

http://www.zhihu.com/question/23654895/answer/25541037

It is not appropriate to take a Canvas with a Pop, although both call themselves the "animation library", but the meaning of the word "library" differs. Essentially, Canvas is an "animation collection" and Pop is an "animation engine."

Say Canvas first. The purpose of the Canvas is "animate in Xcode without code". Developers can implement some of the preset animations in the Canvas by specifying the User Defined Runtime Attributes in Storyboard, which is what they can see on his site. But in addition to changing the animation delay and duration basically can not adjust the other parameters (the site has written a future preparation support but all five months ...) )

Let's consider a bounce left animation, in fact, there is an object from the right to a small vibration and then stop the process. This is what the Canvas does:

+(void)Performanimationonview:(UIView*)ViewDuration(Nstimeinterval)DurationDelay(Nstimeinterval)Delay{StartView.Transform=Cgaffinetransformmaketranslation(300,0);[UIViewAnimatekeyframeswithduration:Duration/4DelayDelayOptions0Animations:^{EndView.Transform=Cgaffinetransformmaketranslation(-10,0);}Completion:^(BOOLFinished){[UIViewAnimatekeyframeswithduration:Duration/4Delay0Options0Animations:^{EndView.Transform=Cgaffinetransformmaketranslation(5,0);}Completion:^(BOOLFinished){[UIViewAnimatekeyframeswithduration:Duration/4Delay0Options0Animations:^{EndView.Transform=Cgaffinetransformmaketranslation(-2,0);}Completion:^(BOOLFinished){[UIViewAnimatekeyframeswithduration:Duration/4 delay:0 options:0 animations:^{ //End view.  Transform = cgaffinetransformmaketranslation(0, 0); } Completion:^(BOOL finished) { }]; }]; }]; }]; }< /c14> 


Nothing special (except the callback nesting is a bit spectacular). But for the general developer is probably the most headache is the transfer of the parameters in the picture, Canvas directly to the parameters of death, although the effect of a little stiff, for the animation of the bitter hand is still helpful.

The components of the Canvas are similar, by specifying the properties in Storyboard to customize the font or the background of the frosted glass (by inserting the uitoolbar to achieve, more coarse) and other effects. It's actually a matter of saving a few lines of code--which is what it's after, of course.

Pop is not the same. If Canvas is the encapsulation of the core Animation, Pop is the re-implementation of the core Animation (and Uidynamics).

Why should it be realized? Back in 2010, when Mike Matas and Kimon Tsinteris started the Push Pop Press. At that time (actually until IOS 7) Core Animation can only do so-called "static animation"-The system provides only four time functions: linear, slow-in, slow-out, slow-in and slow-out. It is cumbersome to use these to simulate physical interactions in the real world. Real-world interactions are like Apple's Uiscrollview: Pull the head and pull it back again, then flick it off and then slowly stop after a stroke. Kimon Tsinteris in introducing Pop, the animation engine behind Paper said that the touch screen makes the operation more direct, so also let people on the screen this media expectations higher: If an object can respond to my tap, It also needs to be able to respond to my gentle strokes.

Unfortunately, Apple did not disclose the technology they used to implement Uiscrollview. It may not be very good to imagine a scroll view without the "elasticity", just as Ole Begemann a time ago. As you can see in the picture at the end of this article at understanding Uiscrollview, this is a scroll view that lets you stop and drag.

and Kimon they want every element in the Push Pop press to have the same experience as Uiscrollview. So they created one of their own animation engines, which needed to add two additional animations: Spring (elastic) and Decay (attenuation). Later in the development of the Paper they further improved the engine, is the Pop we are now seeing.

For example, the same bounce left effect is implemented in Pop:

Popspringanimation*Animation=[PopspringanimationAnimation];Animation.Property=[PopanimatablepropertyPropertywithname:Kpoplayertranslationx];animation. Fromvalue = @300.0; Animation. Tovalue = @0.0; Animation. Springbounciness = 10.0; Animation. Springspeed = 12.0; [view. Layer pop_addanimation:animation forkey:@ "Pop" ;                


Pop syntax is similar to the Core Animation, and the effect is not as stiff as Canvas (time-divided, amplitude hard-coded). This makes it easy for programmers with knowledge of Core Animation to convert the original "static animation" to "animated animation".

At the same time, Pop went a step more forward. Since the essence of animation is to do interpolation based on the time function, then theoretically any one of the values of any object can be used to do interpolation, not just the size of the core Animation, displacement, rotation, scaling and other animatable properties. For example, the text color of a label will fade from yellow to purple, previously not in the Core Animation, and Pop can be used to customize a property to make it easier to implement. Or you can change the size of a view on the fly, change its frame only, and now change the constraints of auto layout, which is a more intuitive approach for people using auto layout.

The problem with Pop, of course, is that the requirements for interaction designers are higher. An elastic animation to have a lot of "play", a decay animation to what speed attenuation, what kind of animation let users feel just right not to steal, this is the problem that designers need to consider. Mike Matas is in the right place.

[Go] IOS Animation Library What are the advantages and disadvantages of Pop and Canvas?

Related Article

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.