Xcode11前后自定义窗口
程序员文章站
2022-06-22 17:10:53
Xcode11前- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Xcode11前生效 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [U...
Xcode11前
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Xcode11前生效
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
UIViewController *vC = [[CustomViewController alloc] init];
self.window.rootViewController = vC;
//window核心化可见
[self.window makeKeyAndVisible];
return YES;
}
Xcode11后
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)) API_AVAILABLE(ios(13.0)) API_AVAILABLE(ios(13.0)){
//Xcode11后生效
//scene行参字段名表象特征结构为UIScene*但持有的实例值的实际特征结构为UIWindowScene*
//强制类型转化
if (@available(iOS 13.0, *)) {
UIWindowScene *windowScene = (UIWindowScene *)scene;
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
} else {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
}
self.window.backgroundColor = [UIColor whiteColor];
UIViewController *vC = [[CustomViewController alloc] init];
self.window.rootViewController = vC;
//window核心化可见
[self.window makeKeyAndVisible];
}
本文地址:https://blog.csdn.net/yanhaijunyan/article/details/111938211