Graphic animation for I/O Development

Source: Internet
Author: User

In iOS development, graphic interface animations generally occur in the following two scenarios:

1. switching between two uiview views has an animation effect.

2. the animation effect of the position, size, or angle rotation of the view itself.

I. Use uiview to implement the animation for switching views, but there are only four styles in the effect of switching views,

Uiviewanimationtransitionflipfromleft, flipped left

Uiviewanimationtransitionflipfromright, flip to the right

Uiviewanimationtransitioncurlup, page up

Uiviewanimationtransitioncurldown, flip down

Implementation Code demo1:

// Start the animation [uiview beginanimations: Nil context: NULL]; // set the animation execution time [uiview setanimationduration: 1.0]; // set the animation effect and specified view. The view set here must be the parent view for changing the child view. (Change the sub-View content when the parent view changes) [uiview setanimationtransition: uiviewanimationtransitioncurlup forview: Self. viewcontainer cache: Yes]; // This is written in the view changes process in the view container. The entire process changes [self. viewcontainer bringsubviewtofront: _ second. view]; // The submitted animation will display the animation effect [uiview commitanimations];

Implementation Code demo2:

// Only use the class method of uiview to switch the view [uiview transitionfromview: view1 toview: view2 Duration: 1.0 options: uiviewanimationoptiontransitioncurlup completion: ^ (bool finished) {nslog (@ "animation completion"); rectovisible =! Rectovisible;}];

Options Value:

Uiviewanimationoptiontransitionflipfromleft

Uiviewanimationoptiontransitionflipfromright, right flip

Uiviewanimationoptiontransitioncurlup

Uiviewanimationoptiontransitioncurldown

Uiviewanimationoptiontransitioncrossdissolve, gradient

Uiviewanimationoptiontransitionflipfromtop, flip

Uiviewanimationoptiontransitionflipfrombottom, flip

Ii. Use the caanimation class to complete the view switching animation. This class can achieve a lot of animation effects.

The effect specified by the system for the Type attribute of caanimation:

Kcatransitionfade: fades out the effect. This effect is the default effect.

Kcatransitionmovein, covering Effect

Kcatransitionpush, extrusion effect

Kcatransitionreveal, Removal Effect

String effect:

@ "Cube" cube Conversion

@ "Suckeffect" absorption effect

@ "Oglflip" Page flip Effect

@ "Rippleeffect" water drop effect

@ "Pagecurl" page up

@ "Pageuncurl" Page flip

@ "Camerairishollowopen" lens expansion effect

@ "Camerairishollowclose" lens close Effect

Subtype attribute of caanimation:

Kcatransitionfromleft,

Kcatransitionfrombottom,

Kcatransitionfromright,

Kcatransitionfromtop

Demo: (viewcontainer is a custom view container)

// Create the object catransition * animation = [catransition animation]; // set the animation execution time to animation. duration = 1.0; // animation type. type = kcatransitionreveal; // animation to animation. subtype = kcatransitionfromtop; // sets the animation execution rate to change to animation. timingfunction = [camediatimingfunction functionwithname: kcamediatimingfunctioneaseout]; // switch the subview [self. viewcontainer bringsubviewtofront: _ second. view]; // Add animation [self. viewcontainer. layer addanimation: animation forkey: @ "Animation"];

 

3. zoom out, move, and rotate an animation

Demo:

// Set the reduced transform to 0.5 times the original size, and 0.8 times the cgaffinetransform scale = cgaffinetransformmakescale (0.5, 0.8); // set the rotated transform and bring it into the reduced scale, rotate to 60 degrees and convert to Radian-based cgaffinetransform rotate = cgaffinetransformrotate (scale, m_pi * 60/180); // place the transform changes in the animation [uiview beginanimations: Nil context: null]; [uiview setanimationduration: 1.0]; // sets the displacement, which is 0 in the X direction and 150 in the Y direction, and combines the first two transform views. transform = cgaffinetransformtranslate (rotate, 0,150); [uiview commitanimations];

 

Graphic animation for I/O Development

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.