iOS 13 statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window 错误


突然的崩溃让我措手不及

*** 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);

               }

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM