Composite animation caanimationgroup

Source: Internet
Author: User

Declare and define a uiimageview in the Custom viewcontroller.

 
1@ Property (nonatomic, retain) uiimageview * imgview;
 
1 @ SynthesizeImgview;

Add an image to the viewdidload function and execute a composite animation.

 1  //  Add Image  
2 Imgview = [[uiimageview alloc] initwithimage: [uiimage imagenamed: @" Icon@2x.png " ];
3 Imgview. Frame = cgrectmake ( 100 , 100 , Imgview. Frame. Size. Width, imgview. Frame. Size. Height );
4 [Self. View addsubview: imgview];
5 [Imgview release];
6
7 // Beiser curve path
8 Uibezierpath * movepath = [uibezierpath bezierpath];
9 [Movepath movetopoint: cgpointmake ( 10.0 , 10.0 )];
10 [Movepath addquadcurvetopoint: cgpointmake ( 100 , 300 ) Controlpoint: cgpointmake ( 300 , 100 )];
11
12 // The following must import the quartzcore package
13 // Key Frame Animation (position)
14 Cakeyframeanimation * posanim = [cakeyframeanimation animationwithkeypath: @" Position " ];
15 Posanim. Path = movepath. cgpath;
16 Posanim. removedoncompletion = yes;
17
18 // Zoom Animation
19 Cabasicanimation * scaleanim = [cabasicanimation animationwithkeypath: @" Transform " ];
20 Scaleanim. fromvalue = [nsvalue valuewithcatransform3d: catransform3didentity];
21 Scaleanim. tovalue = [nsvalue valuewithcatransform3d: catransform3dmakescale ( 0.1 , 0.1 , 1.0 )];
22 Scaleanim. removedoncompletion = yes;
23
24 // Transparent Animation
25 Cabasicanimation * opacityanim = [cabasicanimation animationwithkeypath: @" Alpha " ];
26 Opacityanim. fromvalue = [nsnumber numberwithfloat: 1.0 ];
27 Opacityanim. tovalue = [nsnumber numberwithfloat: 0.1 ];
28 Opacityanim. removedoncompletion = yes;
29
30 // Animation Group
31 Caanimationgroup * animgroup = [caanimationgroup animation];
32 Animgroup. animations = [nsarray arraywithobjects: posanim, scaleanim, opacityanim, nil];
33 Animgroup. Duration =1 ;
34
35 [Imgview. layer addanimation: animgroup forkey: Nil];

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.