zoukankan      html  css  js  c++  java
  • 在启动页面后面再加载一个广告页,可以定制动画等

    这个上面可以加载一些动画等
    该方法要卸载appdelegate里面:
    写到这个方法里面:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     
    要注意  一定要卸载最下面,就是紧挨着  return YES上面,否则加载上以后还会看不到
     
    案例:
    先在.h中声明一个:
    @property (strong, nonatomic) UIImageView *splashView;
     
    然后回到.m文件中:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
       


    //  
    //    调用百度push设置方法
        [self baiduCloudPush:application andDic:launchOptions];
       
        // Override point for customization after application launch.
       
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
        //[self setUM];
        NSArray *paths= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        //获得documents的文件路径
        NSString *documentDirectory=[paths objectAtIndex:0];
        CLog(@"%@",documentDirectory);
        //[self locate];
        HomeViewController *homeVC = [[HomeViewController alloc]init];
        CommunityViewController *communityVC = [[CommunityViewController alloc]init];
        ShopViewController *shopVC = [[ShopViewController alloc]init];
        UserViewController *userCenterVC = [[UserViewController alloc]init];
        CustomTabBarController *MTabBar = [CustomTabBarController sharedCustomTabBarController];
        [MTabBar setViewControllers:[NSArray arrayWithObjects:homeVC,communityVC,shopVC,userCenterVC, nil]];
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:MTabBar];
        nav.navigationBarHidden = YES;
        self.window.rootViewController = nav;
    /*-------------------上面主要是一些配置,下面代码是加载动画---------------*/
      
        //    让试图可见
        [_window makeKeyAndVisible];
       
        //   加载试图一定要写在makeKeyAndVisible方法的下面否则将看不到。
        _splashView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height )];
        //将图片添加到UIImageView对象中
        _splashView.center = self.window.center;
        _splashView.image=[UIImage imageNamed:@"DL_background.png"];
        [self.window addSubview:_splashView];
     
    //将UIImageView显示在window的最上面
        [self.window bringSubviewToFront:_splashView];
       
        [self performSelector:@selector(showWord) withObject:nil afterDelay:0.0f];
       
        return YES;
    }





    -(void)showWord
    {
       
        UIImageView *word_ = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 80, 80)];
        word_.center = self.window.center;
        word_.image = [UIImage imageNamed:@"LOGO"];
        [_splashView addSubview:word_];
       
        word_.alpha = 1.0;
    // 动画执行延时执行1秒,执行1秒  delay表示延时
        [UIView animateWithDuration:1.0f delay:1.0f options:UIViewAnimationOptionCurveLinear
                         animations:^
         {
             word_.alpha = 0.0;
         }
                         completion:^(BOOL finished)
         {
             // 完成后执行code
             [NSThread sleepForTimeInterval:1.0f];
             [_splashView removeFromSuperview];
         }
         ];
    }
  • 相关阅读:
    实验7 BindService模拟通信
    实验6 在应用程序中播放音频和视频
    实验五-数独游戏界面设计
    期中测试-计时器界面设计
    实验4 颜色、字符串资源的使用
    实验三、动态优先数实验
    实验二 作业调度模拟程序
    实验一 命令解释程序的编写
    实验八:SQLite数据库操作
    在应用程序中播放音频和视频
  • 原文地址:https://www.cnblogs.com/AlienY/p/4664414.html
Copyright © 2011-2022 走看看