对比:AppDelegate中 application:didFinishLaunchingWithOptions

Swift

    // 当应用程序启动后将会调用该方法
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        
        // 创建UIWindow对象,并初始化该窗口的大小与主屏幕大小相同
        let rect : CGRect = UIScreen.mainScreen().bounds
        
        // 程序将创建的UIWindow对象赋值给该程序委托对象的window属性
        self.window = UIWindow(frame:rect)
        
        // 创建ViewController对象、并使用ViewController界面布局文件来
        // 初始化该视图控制器关联的用户界面
        let vc = ViewController(nibName: "ViewController", bundle: nil)
        
        // 让该程序的窗口加载、并显示viewController视图控制器关联的用户界面
        self.window?.rootViewController = vc
        
        //设置背景颜色
        self.window?.backgroundColor = UIColor.whiteColor()
        
        // 将该UIWindow对象设为主窗口、并显示出来
        self.window?.makeKeyAndVisible()
        
        return true
    }



Objective-C

// 当应用程序启动后将会调用该方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // 创建UIWindow对象,并初始化该窗口的大小与主屏幕大小相同
    CGRect rect = [[UIScreen mainScreen] bounds];
    // 程序将创建的UIWindow对象赋值给该程序委托对象的window属性
    self.window = [[UIWindow alloc] initWithFrame:rect];
    // Override point for customization after application launch.
    
    // 创建FKViewController对象、并使用FKViewController界面布局文件来
    // 初始化该视图控制器关联的用户界面
    ViewController *vc = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    
    // 让该程序的窗口加载、并显示viewController视图控制器关联的用户界面
    self.window.rootViewController = vc;
    
    //设置背景颜色
    self.window.backgroundColor = [UIColor whiteColor];
    
    // 将该UIWindow对象设为主窗口、并显示出来
    [self.window makeKeyAndVisible];
    
    return YES;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值