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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:10:02  来源:igfitidea点击:

UIStatusBar color change to white when Splash screen showing

iosobjective-ciphonexcode

提问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. enter image description here

它有选择光的选项。 在此处输入图片说明

回答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

Change Status Bar Stylefrom Defaultto Light:

状态栏样式Default更改为Light

enter image description here

在此处输入图片说明

(click for bigger image)

(点击查看大图)

回答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 中更改状态栏的样式。当您从这里更改它时,它也会影响您的启动画面。

Select Target and change the style of status bar 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 故事板并提供您想要提供的视图的自定义背景颜色,它就可以完美运行。