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];