1、AppDelegate.m自定义根视图
self.window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 375, 667)];
FirsteAppViewController * mainViewController = [[FirsteAppViewController alloc] init];
UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
[navigationController setNavigationBarHidden:YES animated:NO];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
2、FirsteAppViewController的viewDidLoad方法,添加2个UIWindow
UIWindow * window1 = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 375/2, 667)];
UIWindow * window2 = [[UIWindow alloc] initWithFrame:CGRectMake(375/2, 0, 375/2, 667)];
[self.view addSubview:window1];
[self.view addSubview:window2];
SecedeAppViewController * ctl = [[SecedeAppViewController alloc] init];
[ctl.view setBackgroundColor:[UIColor blueColor]];
UINavigationController * navigationController1 = [[UINavigationController alloc] initWithRootViewController:ctl];
[navigationController1 setNavigationBarHidden:YES animated:NO];
window1.rootViewController = navigationController1;
[window1 makeKeyAndVisible];
SecedeAppViewController * mainViewController = [[SecedeAppViewController alloc] init];
[mainViewController.view setBackgroundColor:[UIColor yellowColor]];
UINavigationController * navigationController2 = [[UINavigationController alloc] initWithRootViewController:mainViewController];
[navigationController2 setNavigationBarHidden:YES animated:NO];
window2.rootViewController = navigationController2;
[window2 makeKeyAndVisible];
```
3运行,效果如下图所示:
image.png
4、GitHub源码:
网友评论