In iOS development, to do an animation effect, we will use Cakeyframeanimation. This library provides some control over frame animations, what is frame animation? Frame animation is like television animation, by a lattice of pictures (can also be imagined as frame) composition, quickly play the picture is animated. The concept of cakeyframeanimation is the same, you only need to provide keyframe information, the program will automatically complete the "picture" between keyframe. If you have used Adobe Flash this tool, it is equivalent to Motion/shape tween. Well, for example, it's quite clear. If you want to do a pop-up animation of a graphic, use Cakeyframeanimation to write a
This pop-up animation contains 5 Keyframe, which is designed to make a bounce-back feel. [Boundsovershootanimation Setvalues:boundsvalues] This line of code sets the animation's keyframe. Another important element is time, Cakeyframeanimation provides keyframe time control, if not set will be developed in a straight line. And this animation will appear in the form of slow and fast, why? See [Boundsovershootanimation Setkeytimes:times] this passage. Animation of one second, from 0-0 to 5 seconds will be startingsize to targetsize animation, 0.5-0.8 seconds will be targetsize to overshootsize animation. So the analogy will make the first slow and quick effect.
Cakeyframeanimation also provides other ways to control keyframe, and the following is a transparent fade out animation.
Opacityanimation.timingfunction is used to control the linear development of animations. where [Camediatimingfunction functionwithcontrolpoints:1.0:0.0:1.0:0.1] is a control method of a Bezier curve. This also allows the animation to slow down quickly or quickly after the result. You ask, how do I know what the effect will be? Here is a graphical tool to illustrate the digital linear relationship http://netcetera.org/camtf-playground.html
Cakeyframeanimation provides a good feature, but for some of the more complex animation effects, cakeyframeanimation configuration will become complex, the code will be very long. Let's say I'm going to do something like a ball bounce. We want to calculate the position of each keyframe, and then configure the animation time for each keyframe. To make such an effect, there will be a lot of keyframe. So after referencing the tween animation of ActionScript, we developed a tween effect library for iOS. The basic principle is to use some tween function package to calculate the change value of the formula, and then extend cakeyframeanimation automatically according to tween function to calculate keyframe. Here is the effect of the ball beating.
[Easing getbounce] is a formula for the bounce effect in tween animation library. [Cakeyframeanimation animationwithkeypath:@ "position.x" EaseFunction:easingFn.easeOut fromvalue:0.0 tovalue:200] Is the extension of the cakeyframeanimation. The return is a general cakeyframeanimation, which can be used directly on UIView objects. The Tween animation library provides the following effects, which can be graphically http://hosted.zeh.com.br/tweener/docs/en-us/misc/transitions.html
Tween Animation library can be extended. Refer to the following linear formula, T is the current time value, B is the property start value, C is the property change difference, D is the total time value, the return is the value of the T time property. We are free to change to create a new formula.
Finally attach the source code, please message exchange advice.
Http://url.cn/EyBoWa
Thank you for your reading, this article by Tencent Isux Copyright, reprint, please specify the source, the offender will investigate, thank you for your cooperation. Annotated source format: Tencent Isux (http://isux.tencent.com/ios-easing-tween-animation.html)
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.