UIWindow

window相当于个画板,想要展现的图像或则图形,需要把画的东西画在window画板上;
UIWindow继承于UIView,在UI中所有能看的到的东西,都继承于UIView。在iOS中,通常UIWindow来表示,每个APP都要把展现的东西写在UIWindow上。通常一个APP创建一个UIWindow对象。
//
//  AppDelegate.m
//  UIWindow
//  Created by cqy on 16/2/12.
//  Copyright © 2016年 程清杨. All rights reserved.
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //创建UIWindow对象,初始化时设置UIWindow的位置与屏幕相同。
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    //设置UIWindow的背景颜色
    self.window.backgroundColor = [UIColor whiteColor];
    //设置显示UIWindow
    [self.window makeKeyAndVisible];
   
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
注释: 1、initWithFrame:[[UIScreen mainScreen] bounds],初始化window,使这个window跟屏幕⼀样⼤⼩。
2、backgroundColor,设置背景⾊
3、makeKeyAndVisible,把window设置成可显⽰的
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

你可能感兴趣的:(UIWindow)