iOS animation (5) Transition animation

Source: Internet
Author: User

When you need to change the stage background, the stage curtain will slowly close, then open slowly, the content on the stage has changed.

The meaning of transition animation is similar to the stage curtain, when the content on the layer changes, we want to use an animated effect to switch, Coreanimation provides catransition to achieve the transition effect.

- (void) viewdidload{[Super Viewdidload]; Uiimageview*imageview = [[Uiimageview alloc] Initwithframe:cgrectmake ( -, -, -, -)]; Imageview.image= [UIImage imagenamed:@"5.png"];        [Self.view Addsubview:imageview]; Uiimageview*imageview2 = [[Uiimageview alloc] Initwithframe:cgrectmake ( -, -, -, -)]; Imageview2.image= [UIImage imagenamed:@"4.png"]; [Self.view addsubview:imageview2];}- (void) touchesended: (Nsset *) touches withevent: (Uievent *)Event{catransition*transition =[catransition animation]; Transition.type=Kcatransitionmovein; Transition.subtype=Kcatransitionfromleft;
  
Transition.duration = 1;
    [Self.view.layer addanimation:transition forkey:nil];    [Self.view Exchangesubviewatindex: 2 withsubviewatindex:3];}

Catransition two key parameters need to be set: Type and subtype, which control the types of transition animations, which control the direction of transition animation

Type supports the following values

Kcatransitionfade Fade Effect

Kcatransitionmovein Move-in effect

Kcatransitionpush push-in effect

Kcatransitionreveal Uncover Effects

In addition to the above four values, type also supports the following private animations

Cube Cube rotation

Suckeffect Inhalation effect

Oglflip Flip

Rippleeffect Water Wave Animation

Pagecurl Page Uncovered

Pageuncurl PAGE Down

Camerairishollowopen Lens Open

Camerairishollowclose Lens off

The subtype provides four animation orientations and supports the following values

Kcatransitionfromright

Kcatransitionfromleft

Kcatransitionfromtop

Kcatransitionfrombottom

In addition, transition animations can be achieved via UIView's beginanimation:context: and Commitanimation

- (void) viewdidload{[Super Viewdidload]; Uiimageview*imageview = [[Uiimageview alloc] Initwithframe:cgrectmake ( -, -, -, -)]; Imageview.image= [UIImage imagenamed:@"5.png"];        [Self.view Addsubview:imageview]; Uiimageview*imageview2 = [[Uiimageview alloc] Initwithframe:cgrectmake ( -, -, -, -)]; Imageview2.image= [UIImage imagenamed:@"4.png"]; [Self.view addsubview:imageview2];}- (void) touchesended: (Nsset *) touches withevent: (Uievent *)Event{[UIView beginanimations:nil context:nil]; [UIView setanimationduration:0.5];    [UIView Setanimationtransition:uiviewanimationtransitioncurldown ForView:self.view Cache:yes];    [UIView Setanimationcurve:uiviewanimationcurveeasein]; [Self.view Exchangesubviewatindex:2Withsubviewatindex:3]; [UIView commitanimations];}

Setaniamtiontransition supports the following properties

Uiviewanimationtransitionnone No animations

Uiviewanimationtransitionflipfromleft slide in from the left

Uiviewanimationtransitionflipfromright slide in from the right

Uiviewanimationtransitioncurlup opened the pages

Uiviewanimationtransitioncurldown down the pages.

Setaniamtioncurve supports the following properties

Uiviewanimationcurveeaseinout //Slow at beginning and end

Uiviewanimationcurveeasein //slow at beginning

Uiviewanimationcurveeaseout //Slow at end

Uiviewanimationcurvelinear

iOS animation (5) Transition animation

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.