UIWindow
// 旋转事件 --> UIApplication --> UIWindow
/**
* 程序启动完毕就会调用一次
*/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// 1.创建window
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// 2.设置window的背景色
self.window.backgroundColor = [UIColor whiteColor];
MjOneViewController *one = [[MjOneViewController alloc] init];
[self.window addSubview:one.view];
// self.window.rootViewController = one;
// 3.显示window
// [self.window makeKeyAndVisible];
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// 1.创建窗口
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds;
// 2.设置颜色
self.window.backgroundColor = [UIColor redColor];
// 3.显示窗口
// 让window成为keyWindow(主窗口)
// [self.window makeKeyWindow];
// 让window成为keyWindow(主窗口)\并且可见
[self.window makeKeyAndVisible];
// self.window = window;
UITextField *tf = [[UITextField alloc] init];
tf.frame = CGRectMake(10, 10, 100, 30);
tf.borderStyle = UITextBorderStyleRoundedRect;
[self.window addSubview:tf];
// 第2个窗口
self.window2 = [[UIWindow alloc] init];
self.window2.frame = CGRectMake(100, 100, 200, 200);
self.window2.backgroundColor = [UIColor yellowColor];
[self.window2 makeKeyAndVisible];
UITextField *tf2 = [[UITextField alloc] init];
tf2.frame = CGRectMake(50, 50, 70, 40);
tf2.borderStyle = UITextBorderStyleRoundedRect;
[self.window2 addSubview:tf2];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
[btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
[self.window2 addSubview:btn];
return YES;
}