显示启动画面时 UIStatusBar 颜色变为白色
UIStatusBar color change to white when Splash screen showing
如何在启动画面显示时将状态栏文本颜色显示为白色。我正在为 iPhone 使用启动画面的默认图像。
将状态栏样式从默认更改为浅色:
(点击看大图)
在didFinishLaunchingWithOptions
中使用上面的代码
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//也可以在查看Controller.m文件中使用,添加如下代码
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
此外,如果您不想在应用 launch/Splash 屏幕期间显示状态栏,请转到 plist 并设置
状态栏最初是隐藏的=是
启动画面时隐藏状态栏
它可以选择 select 点亮。
是的,您可以在 Target 中更改状态栏的样式。当您从此处更改它时,它也会影响您的初始屏幕。
您也可以在 App Delegate class 中更改状态栏颜色
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
}
这是 swift 代码:
//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))
现在,当您 运行 您的应用程序仍然在初始屏幕中看到白色背景时,只需转到 LaunchScreen 情节提要并提供您想要提供的视图的自定义背景颜色,它就可以完美运行。
如何在启动画面显示时将状态栏文本颜色显示为白色。我正在为 iPhone 使用启动画面的默认图像。
将状态栏样式从默认更改为浅色:
(点击看大图)
在didFinishLaunchingWithOptions
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//也可以在查看Controller.m文件中使用,添加如下代码
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
此外,如果您不想在应用 launch/Splash 屏幕期间显示状态栏,请转到 plist 并设置
状态栏最初是隐藏的=是
启动画面时隐藏状态栏
它可以选择 select 点亮。
是的,您可以在 Target 中更改状态栏的样式。当您从此处更改它时,它也会影响您的初始屏幕。
// 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
}
这是 swift 代码:
//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))
现在,当您 运行 您的应用程序仍然在初始屏幕中看到白色背景时,只需转到 LaunchScreen 情节提要并提供您想要提供的视图的自定义背景颜色,它就可以完美运行。