iOS animation Learning (-) UIView self-animating

Source: Internet
Author: User

In iOS development, some common simple animations can be animated with uivew to achieve

Learn about UIVIew some popular animations today

1.

Flipped animation    [UIView beginanimations:@ "Doflip" context:nil];    settings are often    [UIView setanimationduration:1];    Set animation fade    [UIView setanimationcurve:uiviewanimationcurveeaseinout];    Set Agent    [UIView setanimationdelegate:self];    Set rollover Direction    [UIView setanimationtransition:     uiviewanimationtransitionflipfromleft  Forview: Self.redview Cache:yes];    End of animation    [UIView commitanimations];

Effect:

2. Displacement animation

[UIView beginanimations:@ "move"  Context:nil];    [UIView setanimationduration: 2 ];    [UIView setanimationdelegate:self];     // Change the value    of x, y of its frame Self.redview.frame=cgrectmake (+);    [UIView commitanimations];

Effect:

Another way to do this:

[UIView animatewithduration:0.5 delay:0.1 usingspringwithdamping:0.5 initialspringvelocity:5.0 options: Uiviewanimationoptioncurveeaseinout animations:^{        Cgpoint point = _redview.center;        Point.y + =;        [_redview setcenter:point];    } completion:^ (BOOL finished) {            }];

Effect:

3. Keyframe Animation

 void (^keyframeblock) () = ^ () {//Create color array nsarray *arraycolors = @[[uicolor Orangecolor],                                 [Uicolor Yellowcolor], [Uicolor Greencolor], [Uicolor Bluecolor], [Uicolor Purplecolor], [Uicolor REDC        Olor]];        Nsuinteger Colorcount = [arraycolors count];  Loop add Keyframe for (Nsuinteger i = 0; i < Colorcount; i++) {[UIView addkeyframewithrelativestarttime:i/                                          (cgfloat) Colorcount relativeduration:1/(cgfloat) Colorcount                                          animations:^{[_redview Setbackgroundcolor:arraycolors[i]];        }];    }    }; [UIView animatekeyframeswithduration:5.0 delay:0.0 Optio Ns:uiviewkeyframeAnimationoptioncalculationmodecubic | Uiviewanimationoptioncurvelinear Animations:keyframeblock Comple                              tion:^ (BOOL finished) {//After the animation is completed//code ... }];

Effect:

iOS animation Learning (-) UIView self-animating

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.