AppDelegate.m
- (void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
self.window.backgroundColor = [UIColor redColor];
/*
makeKeyAndVisible的作用:
1.让window在屏幕上直接显示,这是window的属性,view没有这个属性,如果室view,需要添加到其他的视图上显示
2.将当前窗口设置为主窗口
*/
[_window makeKeyAndVisible];
_window.windowLevel = UIWindowLevelStatusBar;
UIWindow *w2 = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 90, 90)];
w2.backgroundColor = [UIColor greenColor];
// [w2 makeKeyAndVisible]; 不能这么写
//hidden的作用:在主窗口上显示w2,但是w2不是主窗口
w2.hidden = NO;
/*
设置window的优先级:UIWindowLevelNormal < UIWindowLevelStatusBar < UIWindowLevelAlert;
默认是:UIWindowLevelNormal
*/
w2.windowLevel = UIWindowLevelAlert;
//拿到当前程序的主window
UIWindow *w3 = application.keyWindow;
NSLog(@"self.window:%@",self.window);
NSLog(@"w3:%@",w3);
return YES;
}