突然的崩溃让我措手不及
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'
修改方式
if (@available(iOS 13.0, *)) {
// iOS 13 弃用keyWindow属性 从所有windowl数组中取
UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;
statusBar.backgroundColor =UIColorFromHex(0x3757d8);
[[UIApplication sharedApplication].keyWindow addSubview:statusBar];
}else{
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = UIColorFromHex(0x3757d8);
}
}