UIWindow

    //程序启动流程
    //main
    //UIApplicationMain
    //初始化UIAppliaction(创建&设置代理&开启Runloop)
    //监听系统事件
    //didFinishLaunchingWithOptions
    //applicationWillResignActive
    //... 
    //创建UIWindow
    //创建控制器的View
    //将控制器的View添加到window上
    //infoplist文件中如果有Main storyboard file base name:Main 则会加载MainStoryboard
    //加载之前创建一个窗口UIWindow
    //把MainStoryboard所指向的控制器设置为窗口window的根控制器
    //显示窗口Window(根控制器的view添加到window上)
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    self.window.layer.backgroundColor = [UIColor redColor].CGColor;
    
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view.backgroundColor = [UIColor grayColor];
    
    self.window.rootViewController = vc;
    
    //设置应用程序的主窗口(在此之前window是隐藏的)
    [self.window makeKeyAndVisible];
    //相当于下面两行代码
    //self.window.hidden = NO;
    //[self.window addSubview:vc.view];
    NSLog(@"%@",[UIApplication sharedApplication].delegate.window);

你可能感兴趣的:(UIWindow)