在启动页面后面再加载一个广告页,可以定制动画等

这个上面可以加载一些动画等
该方法要卸载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];
     }
     ];
}
posted on 2015-07-21 14:31  AlienStar  阅读(184)  评论(0编辑  收藏  举报