关于开机动画的问题

今天就和大家分享一下关于IOSAPP开机动画的问题,因为在ios的程序中启动图是一张静止的图片,所以要做开机动画必须要在appDelegate里面进行,将动画代码写在didFinishLaunchingWithOptions的方法里面,代码如下:

注意:在执行动画的时候必须先选择主控制器,这样动画才能进行,小编在写完程序的时候,曾经把下面红色代码删除,造成启动时动画丢失的情况,请广大程序猿注意!

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

    [self.window makeKeyAndVisible];

    self.window.backgroundColor = [UIColor whiteColor];

    self.splashView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];

    self.splashView.userInteractionEnabled = YES;

    self.splashView.image = [UIImage imageNamed:@"new_feature_0"];

    [self.window addSubview:self.splashView];

    [self.window bringSubviewToFront:self.splashView];

    [self performSelector:@selector(scale_1) withObject:nil afterDelay:0.0f];

    [self performSelector:@selector(showWord) withObject:nil afterDelay:0.0f];

    

    [UIView animateWithDuration:0 delay:4 options:UIViewAnimationOptionAllowUserInteraction animations:^{

        HXTabBarController *tabBarCV = [HXTabBarController new];

        [tabBarCV.tabBar removeFromSuperview];

        self.window.rootViewController = tabBarCV;

    } completion:^(BOOL finished) {

        //设置根控制器

        self.key = @"CFBundleShortVersionString";

        //上一次的使用版本(存储在沙盒中的版本号号)

        NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:self.key];

        //当前软件的版本号(conginfo.plist中获得)

        NSString *currentVersion = [NSBundle mainBundle].infoDictionary[self.key];

        //版本号相同,这次打开和上次打开的是同一个版本

        if ([currentVersion isEqualToString:lastVersion]) {

            UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

            HXTabBarController *tabBarC = [story instantiateInitialViewController];

            self.tabBarController = tabBarC;

            self.window.rootViewController = tabBarC;

        } else {

            //这次打开的版本和上次不一样,显示新特性

            self.window.rootViewController = [[HXNewFeatureController alloc] init];

            //将当前的版本号存近沙盒

            [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:self.key];

            [[NSUserDefaults standardUserDefaults] synchronize];

        }

        [self.splashView removeFromSuperview];

    }];

    return YES;

}

-(void)scale_1

{

    UIImageView *dragon = [[UIImageView alloc]init];

    dragon.image = [UIImage imageNamed:@"dragon"];

    dragon.width = 1;

    dragon.height = 1;

    [self.splashView addSubview:dragon];

    [self setDragon:dragon];

}


-(void)setDragon:(UIImageView *)nowView

{

    

    [UIView animateWithDuration:2 animations:^{

        nowView.width = 173;

        nowView.height = 227;

        nowView.centerX = self.splashView.centerX;

        nowView.centerY = self.splashView.height * 0.35;

    }completion:^(BOOL finished){

    }];

}


-(void)showWord

{

    

    UIImageView *honorable = [[UIImageView alloc]init];

    honorable.image = [UIImage imageNamed:@"honorable"];

    honorable.width = 250;

    honorable.height = 90;

    honorable.centerX = self.splashView.centerX;

    honorable.y = self.splashView.height - 200;

    [self.splashView addSubview:honorable];

    honorable.alpha = 0.0;

    [UIView animateWithDuration:2.0f delay:0.0f options:UIViewAnimationOptionCurveLinear

                     animations:^{

                         honorable.alpha = 1.0;

                     }completion:^(BOOL finished){

                         // 完成后执行code

                         [NSThread sleepForTimeInterval:2.0f];

                         

                     }];

}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值