Thread 1: Exception: "App called
2020-08-29 本文已影响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;
}
}
}