所以我要花一些时间在项目上,试图重新尝试我的“技能”,这使我想到了这个问题。
我确实一切正常。解决“ iOS 13.0中不推荐使用的keyWindow”错误。
我仅在项目中使用Objective-C,因为这是我目前最了解的知识。
当前方式:
-(UIColor*)statusBarColor
{
UIColor *color = [UIColor colorWithRed:45/255.0f green:45/255.0f blue:45/255.0f alpha:1.0f];
return color;
}
- (void)setStatusBarBackgroundColor:(UIColor *)color
{
if (@available(iOS 13, *)) {
UIView *view = [[UIView alloc]initWithFrame:[[UIApplication sharedApplication] delegate].window.windowScene.statusBarManager.statusBarFrame] ;
[[[UIApplication sharedApplication] delegate].window addSubview:view];
if ([view respondsToSelector:@selector(setBackgroundColor:)]) {
view.backgroundColor = color;
}
}
}
然后我在viewDidLoad / viewWillAppear中调用该块。
[self setStatusBarBackgroundColor:[self statusBarColor]];
所以我想我的主要问题是,是否有更好的方法来实现这一目标?特别是在Objective-C中?如果我决定最后提交,这是否对AppStore安全?
谢谢。