. H
#import <UIKit/UIKit.h>@interface RootViewController : UIViewController{ NSTimer *timer; UIImageView *imageView1; UIImageView *imageView2; UIImageView *imageView3; UIView * view1; UIView * view2; UIView * view3;}@end
. M
-(Void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view. // initialize the background image [self initbackgroundview];} # pragma-mark-funcitons-(void) initbackgroundview {// view1 = [[uiview alloc] initwithframe: cgrectmake (0, 0,320,560)]; [self. view addsubview: view1]; imageview1 = [[uiimageview alloc] initwithframe: cgrectmake (0, 0,420,560)]; imageview1.image = [uiimage imagenamed: @ "guidex1.png"]; [view1 addsubview: imageview1]; // the second picture view2 = [[uiview alloc] initwithframe: cgrectmake (0, 0,320,560)]; [self. view addsubview: view2]; imageview2 = [[uiimageview alloc] initwithframe: cgrectmake (0, 0,420,560)]; imageview2.image = [uiimage imagenamed: @ "guidex2.png"]; [view2 addsubview: imageview2]; // The third picture view3 = [[uiview alloc] initwithframe: cgrectmake (0, 0,320,560)]; [self. view addsubview: view3]; imageview3 = [[uiimageview alloc] initwithframe: cgrectmake (0, 0,520,660)]; imageview3.image = [uiimage imagenamed: @ "guidex0.png"]; [view3 addsubview: imageview3]; // enable the animation Event timer = [nstimer scheduledtimerwithtimeinterval: 1.0 target: Self selector: @ selector (changeview) userinfo: Nil repeats: No];}-(void) change {[uiview beginanimations: Nil context: Nil]; [uiview setanimationduration: 11.0]; imageview1.frame = cgrectmake (0, 0,320,460); [uiview commitanimations];}-(void) change1 {[uiview beginanimations: Nil context: Nil]; [uiview setanimationduration: 11.0]; imageview2.frame = cgrectmake (0, 0,320,460); [uiview commitanimations];}-(void) change2 {[uiview beginanimations: Nil context: Nil]; [uiview setanimationduration: 11.0]; imageview3.frame = cgrectmake (0, 0,320,460); [uiview commitanimations];}-(void) changeview {imageview1.frame = cgrectmake (0, 0,520,660); [self Change2]; catransition * transition = [catransition animation]; transition. duration = 2.0; // Interval Transition. timingfunction = uiviewanimationcurveeaseinout; // slow down the animation transition. type = kcatransitionfade; // various effects of transition. subtype = kcatransitionfromright; transition. delegate = self; // proxy. the built-in method does not use the Protocol [self. view. layer addanimation: Transition forkey: Nil]; [self. view exchangesubviewatindex: 0 withsubviewatindex: 1]; timer = [nstimer failed: 11.0 target: Self selector: @ selector (changeview1) userinfo: Nil repeats: No];}-(void) changeview1 {imageview2.frame = cgrectmake (0, 0,520,660); [self change]; catransition * transition = [catransition animation]; transition. duration = 2.0; // Interval Transition. timingfunction = uiviewanimationcurveeaseinout; // slow down the animation transition. type = kcatransitionfade; // various effects of transition. subtype = kcatransitionfromright; transition. delegate = self; // proxy. the built-in method does not use the Protocol [self. view. layer addanimation: Transition forkey: Nil]; [self. view exchangesubviewatindex: 1 withsubviewatindex: 2]; timer = [nstimer failed: 11.0 target: Self selector: @ selector (changeview2) userinfo: Nil repeats: No];}-(void) changeview2 {imageview3.frame = cgrectmake (0, 0,520,660); [self Change1]; catransition * transition = [catransition animation]; transition. duration = 2.0; // Interval Transition. timingfunction = uiviewanimationcurveeaseinout; // slow down the animation transition. type = kcatransitionfade; // various effects of transition. subtype = kcatransitionfromright; transition. delegate = self; // proxy. the built-in method does not use the Protocol [self. view. layer addanimation: Transition forkey: Nil]; [self. view exchangesubviewatindex: 2 withsubviewatindex: 0]; timer = [nst1_scheduledtimerwithtimeinterval: 11.0 target: Self selector: @ selector (changeview) userinfo: Nil repeats: No];}
Three pictures on the homepage have animation Effects