程序启动动画

#import <UIKit/UIKit.h>


@interface AppDelegate :UIResponder <UIApplicationDelegate>

@property (strong,nonatomic) UIImageView *splashView;

@property (strong,nonatomic) UIWindow *window;



@end


#import "AppDelegate.h"


@interface AppDelegate ()


@end


@implementation AppDelegate


-(void)scale_1

{

   UIImageView *round_1 = [[UIImageViewalloc]initWithFrame:CGRectMake(100,240, 15, 15)];

    round_1.image = [UIImageimageNamed:@"image_05"];

    [_splashViewaddSubview:round_1];

    [selfsetAnimation:round_1];

}


-(void)scale_2

{

   UIImageView *round_2 = [[UIImageViewalloc]initWithFrame:CGRectMake(105,210, 20, 20)];

    round_2.image = [UIImageimageNamed:@"image_05"];

    [_splashViewaddSubview:round_2];

    [selfsetAnimation:round_2];

}


-(void)scale_3

{

   UIImageView *round_3 = [[UIImageViewalloc]initWithFrame:CGRectMake(125,170, 30, 30)];

    round_3.image = [UIImageimageNamed:@"image_04"];

    [_splashViewaddSubview:round_3];

    [selfsetAnimation:round_3];

}


-(void)scale_4

{

   UIImageView *round_4 = [[UIImageViewalloc]initWithFrame:CGRectMake(160,135, 40, 40)];

    round_4.image = [UIImageimageNamed:@"Image_03"];

    [_splashViewaddSubview:round_4];

    [selfsetAnimation:round_4];

}


-(void)scale_5

{

   UIImageView *heart_1 = [[UIImageViewalloc]initWithFrame:CGRectMake(130,180, 100, 100)];

    heart_1.image = [UIImageimageNamed:@"image_02"];

    [_splashViewaddSubview:heart_1];

    [selfsetAnimation:heart_1];

}


-(void)setAnimation:(UIImageView *)nowView

{

    

    [UIViewanimateWithDuration:0.6fdelay:0.0foptions:UIViewAnimationOptionCurveLinear

                    animations:^

     {

         // 执行的动画code

         [nowViewsetFrame:CGRectMake(nowView.frame.origin.x- nowView.frame.size.width*0.1, nowView.frame.origin.y-nowView.frame.size.height*0.1, nowView.frame.size.width*1.2, nowView.frame.size.height*1.2)];

     }

                    completion:^(BOOL finished)

     {

         // 完成后执行code

         [nowViewremoveFromSuperview];

     }

     ];

    

    

}


-(void)showWord

{

    

   UIImageView *imageView= [[UIImageViewalloc]initWithFrame:CGRectMake(75,440, 170, 29)];

    imageView.image = [UIImageimageNamed:@"image_01"];

    [_splashViewaddSubview:imageView];

    

    imageView.alpha =0.0;

    [UIViewanimateWithDuration:1.0fdelay:0.0foptions:UIViewAnimationOptionCurveLinear

                    animations:^

     {

         imageView.alpha =1.0;

     }

                    completion:^(BOOL finished)

     {

         // 完成后执行code

         [NSThreadsleepForTimeInterval:1.0f];

         [_splashViewremoveFromSuperview];

     }

     ];

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [self.windowmakeKeyAndVisible];

    

    _splashView = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0, 320,568)];

    [_splashViewsetImage:[UIImageimageNamed:@"00"]];

    

    [self.windowaddSubview:_splashView];

    [self.windowbringSubviewToFront:_splashView];

    

    

    [selfperformSelector:@selector(scale_1)withObject:nilafterDelay:0.0f];

    [selfperformSelector:@selector(scale_2)withObject:nilafterDelay:0.5f];

    [selfperformSelector:@selector(scale_3)withObject:nilafterDelay:1.0f];

    [selfperformSelector:@selector(scale_4)withObject:nilafterDelay:1.5f];

    [selfperformSelector:@selector(scale_5)withObject:nilafterDelay:2.0f];

    [selfperformSelector:@selector(showWord)withObject:nilafterDelay:2.5f];

   return YES;

}

- (void)applicationWillResignActive:(UIApplication *)application {

    UIAlertView *u = [[UIAlertView alloc]initWithTitle:@"后台调用:applicationWillResignActive" message:@"当应用即将后台时调用" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"返回", nil];

    [u show];


}


- (void)applicationDidBecomeActive:(UIApplication *)application {

    UIAlertView *u = [[UIAlertView alloc]initWithTitle:@"后台调用:applicationDidBecomeActive" message:@"当应用恢复前台状态时调用" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"返回", nil];

    [u show];

}




猜你喜欢

转载自blog.csdn.net/chungeshihuatian/article/details/45951185