IOS animation implementation

Source: Internet
Author: User
Reproduced http://blog.163.com/wangy_0223/blog/static/45014661201222694654895/
 
You need to add quartzcore in frameworks. framework adds the header file # import <quartzcore/quartzcore in the interface program. h>/* many animation effects */catransition * transition = [catransition animation]; transition. duration = 1.0f;/* interval */transition. timingfunction = [camediatimingfunction functionwithname: kcamediatimingfunctioneaseineaseout];/* speed of starting and ending an animation */transition. type = @ "rippleeffect";/* Various animation effects * // @ "cube" @ "movein" @ "reveal" @ "Fade" (default )@" Pagecurl "@" pageuncurl "@" suckeffect "@" rippleeffect "@" oglflip "transition. subtype = kcatransitionfromright;/* animation direction */transition. delegate = self; [navigationcontroller. view. layer/* Add the Code */addanimation: Transition forkey: Nil] on the layer where you want to add a ca animation. // Add another sentence, transition uses the + method during application, so you do not need to perform the release on your own. Do not consider retaincount as already + 1 after adding a retaincount on the layer, the release // actually has another attribute in the catransition class: removedoncompletion, which is automatically removed after the animation is executed. The default value is true. There are two main methods for iPhone beautiful 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 effects. Here we will write a common sample code for your reference. [Uiview beginanimations: @ "curl" context: Nil]; // The animation starts [uiview setanimationduration: 0.75]; [uiview setanimationdelegate: Self]; [uiview setanimationtransition: Previous 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: catransition * animation = [catransition animation]; [animation setduration: 1.25f]; [animation settimingfunction: [Animation: animation]; [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: settype: four types can be returned: kcatransitionfade fade-out overwrite the source image kcatransitionpush. The kcatransitionreveal bottom shows setsubtype: there can also be four types: kcatransitionfrom; kcatransitionfromleft (default) kcatransitionfromtop; there is also a method for setting the animation type without setsubtype or settype [animation settype: @ "suckeffect"]. suckeffect here is the effect name, available effects: pagecurl flip one page up pageuncurl flip one page down rippleeffect drop effect suckeffect shrink effect, such as a piece of cloth is drawn from cube effect oglflip flip up and down effect

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.