美文网首页
Thread 1: Exception: "App called

Thread 1: Exception: "App called

作者: 一个半吊子工程师 | 来源:发表于2020-08-29 10:54 被阅读0次
- (void)setStatusBarBackgroundColor:(UIColor *)color {
    if (@available(iOS 13.0, *)) {
      // iOS 13  弃用keyWindow属性  从所有windowl数组中取
      UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;
      statusBar.backgroundColor = color;
      [[UIApplication sharedApplication].keyWindow addSubview:statusBar];
    }else{
       UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
       if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
           statusBar.backgroundColor = color;
       }
    }
}

相关文章

网友评论

      本文标题:Thread 1: Exception: "App called

      本文链接:https://www.haomeiwen.com/subject/sibdsktx.html