Animation effect type and implementation method of iOS

Source: Internet
Author: User

There are two main ways to achieve beautiful animations in iOS

One is at the UIView level,

One is to use catransition for lower levels of control,

The first is that the Uiview,uiview method may be used in the lower layer is also the use of catransition encapsulation, it can only be used for some simple, common effects show, here write a common sample code for your reference.

[UIView beginanimations:@ "Curl" context:nil];//animation starts [UIView setanimationduration:0.75]; [UIView setanimationdelegate:self]; [UIView Setanimationtransition:uiviewanimationtransitioncurlup Forview:myview Cache:yes]; [MyView Removefromsuperview]; [UIView commitanimations];

The second approach is relatively complex, but if you have better control, use this method,

The basic use of the method can look at the following example:

Catransition *animation = [catransition animation]; [Animation setduration:1.25f]; [Animation settimingfunction:[camediatimingfunction Functionwithname:kcamediatimingfunctioneasein]; [Animation Settype:kcatransitionreveal]; [Animation Setsubtype:kcatransitionfrombottom]; [Self.view.layer addanimation:animation forkey:@ "Reveal"];

The combination of Settype and Setsubtype is used here, which uses a comparison insurance because his parameters are defined in the official API, and their parameter descriptions can be referenced as follows:

[Animation settype:@ "Suckeffect"];

Here the Suckeffect is the effect name, the effect can be used mainly:

Pagecurl up a page pageuncurl down a page rippleeffect drop effect suckeffect shrinkage effect, such as a piece of cloth was pumped cube effect oglflip up and down flip effect

Finally, we give a common code for your reference.

Curl the image up or down  catransition *animation = [Catransition animation]; [animation setDuration:0 .35]; [animation settimingfunction:uiviewanimationcurveeaseinout];  if (!curled)    {        //animation.type = @ "Mapcurl";          Animation.type = @ "Pagecurl";         Animation.fillmode = kcafillmodeforwards;          animation.endprogress = 0.99;    } else {       //animation.type = @ " Mapuncurl ";        animation.type = @" Pageuncurl ";         Animation.fillmode = Kcafillmodebackwards; Animation.startprogress = 0.01;  }  [animation Setremovedoncompletion:no]; [View exchangesubviewatindex:0 withsubviewatindex:1]; [view addanimation:animation ForKey "PageCurlAnimation"] ;  //Disable user interaction where necessary   if (!curled) { }   else {   }  curled =!curled;  Reprint Original  http://www.cnblogs.com/lovewx/p/3912417.html

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.