Types and implementation methods of iPhone animation effects (Collection)

Source: Internet
Author: User
There are two main ways to achieve beautiful iPhone animation effects: one is at the uiview level, the other is to use catransition for lower-level control, and the first is uiview, the uiview method may also be encapsulated using catransition in the lower layer. It can only be used for some simple and common effect presentations. Here is a common example. Code For your reference. CPP Code [uiview beginanimations: @ "curl" context: Nil]; // animation start [uiview setanimationduration: 0.75]; [uiview setanimationdelegate: Self]; [uiview setanimationtransition: preview forview: myview cache: Yes]; [myview removefromsuperview]; [uiview commitanimations]; The second method is relatively complicated, but if it is better to control it, use this method, for basic usage, see the following example: CPP Code catransition * animation = [catransition animation]; [animation setduration: 1.25f]; [animation settimingfunction: [camediatimingfunction functionwithname: birthday]; [animation settype: kcatransitionreveal]; [animation setsubtype: kcatransitionfrombottom]; [self. view. layer addanimation: animation forkey: @ "reveal"]; The settype and setsubtype combination are used here, which is relatively safe because their parameters are defined in the official API, their parameter descriptions can be referred to as follows: [animation settype: @ "suckeffect"]; suckeffect here is the effect name, and the main effects can be used: CPP Code pagecurl up one page pageuncurl down one page rippleeffect dripping effect suckeffect contraction effect, such as a piece of cloth is extracted from the Cube cube Body Effect oglflip flip up and down effect I have been using the latter for a lot of nice lightweight animations. you can use it crossfade two views, or fade one in front of another, or fade it out. you can shoot a view over another like a banner, you can make a view stretch or shrink... i'm getting a lot of mileage out of beginanimation/commitanimations. don't think that all you can do is: [uiview setanimationtransition: uiviewanimationtransitionflipfromright forview: myview cache: Yes]; here is a sample: [uiview beginanimations: Nil context: NULL]; {[uiview setanimationcurve: uiviewanimationcurveeaseinout]; [uiview setanimationduration: 1.0]; [uiview setanimationdelegate: Self]; If (movingviewin) {// After the animation is over, call afteranimationproceedwithgame // to start the game [uiview setanimationdidstopselector: @ selector (afteranimationproceedwithgame)]; // [uiview setanimationrepeatcount: 5.0]; // don't forget you can repeat an animation // [uiview setanimationdelay: 0.50]; // [uiview setanimationrepeatautoreverses: Yes]; gameview. alpha = 1.0; topgameview. alpha = 1.0; viewrect1.origin. y = selfrect. size. height-(viewrect1.size. height); viewrect2.origin. y =-20; topgameview. alpha = 1.0;} else {// call putbackstatusbar after animation to restore the State after this animation [uiview setanimationdidstopselector: @ selector (putbackstatusbar)]; gameview. alpha = 0.0; topgameview. alpha = 0.0;} [gameview setframe: viewrect1]; [topgameview setframe: viewrect2];} [uiview commitanimations]; as you can see, you can play with Alpha, frames, and even sizes of a view. play around. you may be surprised with its capabilities. ==================== dashed & solid line when using cgcontext drawingto get dashed line: cgcontextref context = uigraphicsgetcurrentcontext (); float dash [2] = {6, 5}; // pattern 6 times "solid", 5 times "empty" cgcontextsetlinedash (context, 0, Dash, 2 ); to get back to solid line: Float normal [1] = {1}; cgcontextsetlinedash (context, 0, normal, 0 );

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.