xcode 闪屏显示时 UIStatusBar 颜色变为白色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30299332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UIStatusBar color change to white when Splash screen showing
提问by Santu C
How to show Status Bar text color white when Splash screen is showing. I am using Default image for Splash screen for iPhone.
如何在显示启动画面时显示状态栏文本颜色为白色。我正在为 iPhone 的启动画面使用默认图像。
回答by Anni S
It has option to select light.
它有选择光的选项。
回答by Mukesh
Use the above code in didFinishLaunchingWithOptions
使用上面的代码 didFinishLaunchingWithOptions
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//You can also use in View Controller.m file and add the following code
//也可以在ViewController.m文件中使用并添加如下代码
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
Also if you don't want the status bar during app launch/Splash screen go to plist and set
此外,如果您不希望在应用程序启动/启动画面期间出现状态栏,请转到 plist 并设置
Status bar is initially hidden=YES
状态栏最初是隐藏的=YES
It will hide the status bar during splash screen
它将在启动画面期间隐藏状态栏
回答by Matthias Bauch
回答by Chandni
Yes, you can change the style of the status bar in Target. When you change it from here it will impact in your splash screen too.
是的,您可以在 Target 中更改状态栏的样式。当您从这里更改它时,它也会影响您的启动画面。
You can change your status bar color in app delegate class too
Objective C Code:
您也可以在应用程序委托类中更改状态栏颜色 Objective C 代码:
// Change the status bar
UIApplication.sharedApplication.statusBarStyle = UIStatusBarStyleLightContent;
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = [UIColor colorWithRed:(254.0/255.0) green:(87.0/255.0) blue:(66.0/255.0) alpha:1.0];//set whatever color you like
}
Here is the swift code:
这是快速代码:
//Status bar style and visibility
UIApplication.shared.statusBarStyle = .lightContent
//Change status bar color
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
statusBar.backgroundColor = UIColor(red: CGFloat(254.0/255.0), green: CGFloat(87.0/255.0), blue: CGFloat(66.0/255.0), alpha: CGFloat(1.0))
Now, when you run your application you still see white background in splash screen just go to LaunchScreen storyboard and give the custom background color of the view which you want to give and it works perfectly.
现在,当您运行您的应用程序时,您仍然会在启动画面中看到白色背景,只需转到 LaunchScreen 故事板并提供您想要提供的视图的自定义背景颜色,它就可以完美运行。