About Core Animation

Source: Internet
Author: User

1. When we create animations using core animatioin, we essentially change the properties of the Calayer and then let these properties flow smoothly. You can animate using the location, color, transparency, and cgaffine transformations of the core animation objects.

2, a simple small animation

/Implicit animation/

-(void) viewdidload {

[Super viewdidload];

uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake( 0, 0, (+ ))];

[UIView beginanimations:nil context:NULL];

[UIView setanimationduration:2.0]; // set animation duration

cgaffinetransform movetransform = cgaffinetransformmaketranslation( 300  ); // move to a fixed position

[ImageView. layer setaffinetransform: movetransform];

ImageView. layer. Opacity = 1;

[UIView commitanimations];

ImageView. backgroundcolor = [uicolor redcolor];

[self. View addsubview: ImageView];

}

/Show Animation/

-(void) viewdidload {

[Super viewdidload];

uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake( 0, 0, (+ ))];

ImageView. backgroundcolor = [uicolor redcolor];

cabasicanimation *opanim = [cabasicanimation animationwithkeypath:@ "opacity"];

Opanim. Duration = 3.0;

// define start and end transparency

Opanim. fromvalue = [nsnumber numberwithfloat:1.0];

Opanim. tovalue = [nsnumber numberwithfloat:0];

Opanim. cumulative = YES;

Opanim.    repeatcount = 6; // number of repetitions

[ImageView. layer addanimation: Opanim forkey:@ "animateopacity"];

cgaffinetransform movetransform = cgaffinetransformmaketranslation( 300 );

cabasicanimation *moveanim = [cabasicanimation animationwithkeypath:@ "transform "];

Moveanim. Duration = 6.0;

Moveanim. tovalue = [nsvalue valuewithcatransform3d:catransform3dmakeaffinetransform( Movetransform)];

[ImageView. layer addanimation: Moveanim forkey:@ "Animatetransform"];

[self. View addsubview: ImageView];

About Core 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.