天天看點

如何實作app檔案,第一次使用時的啟動畫面

//  Created by lyz on 15-8-24.

//  Copyright (c) 2015年 mac. All rights reserved.

//

#import "AppDelegate.h"

//#import "MainTabBarController.h"

#import "FastComeViewController.h"

#import "LunchViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

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

    // Override point for customization after application launch.

     UIWindow *window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

    window.backgroundColor = [UIColor whiteColor];

    self.window = window;

    [self.window makeKeyAndVisible];

    //建立标簽控制器

    //先找檔案,判斷是否存在

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    BOOL value = [defaults boolForKey:@"isnext"];

    if (value == YES)

    {// 不是第一次

        NSLog(@"不是第一次進入");

        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Lunch" bundle:nil];

        LunchViewController *lunch = [storyBoard instantiateViewControllerWithIdentifier:@"Lunch"];

        self.window.rootViewController = lunch;

    }else{

       //第一次

        NSLog(@"第一次進入");

        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

         [defaults setBool:YES forKey: @"isnext"];

        //同步資料

        [defaults synchronize];

        FastComeViewController *tabarVC = [[FastComeViewController alloc]init];

        tabarVC.view.layer.transform = CATransform3DMakeScale(.5, .5, 0);

        self.window.rootViewController = tabarVC;

        [UIView animateWithDuration:1 animations:^{

            tabarVC.view.layer.transform = CATransform3DIdentity;

        }];

        //application.statusBarHidden = NO;

    }

    //狀态欄

    [application setStatusBarStyle:UIStatusBarStyleLightContent];

    return YES;

}