ios - 状态栏在 iPhone 4S 上不显示

标签 ios objective-c statusbar

我将状态栏设置为 UIStatusBarStyleLightContent,并且在所有其他设备(5、5S、6、6 Plus)中,状态栏以白色文本显示。我的应用程序的背景颜色是黑色,因此状态栏有黑色背景,这就是为什么我需要状态栏文本为白色。

所以只有在4S上测试时,状态栏文字才显示为黑色。这是一个已知的错误?是否有任何解决方法可以使 4S 具有正确的状态栏样式?

这就是我这样做的原因

在 AppDelegate 中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    application.statusBarStyle = UIStatusBarStyleLightContent;
}

在我的应用程序中的每个 ViewController 中,我将其放入 viewDidLoad 并添加此方法:

- (void) viewDidLoad {
    [self setNeedsStatusBarAppearanceUpdate];
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

此外,在我的 info.plist 中我有这个:

Status bar style = UIStatusBarStyleLightContent

最佳答案

你试过吗?

在 Info.plist 中将“查看基于 Controller 的状态栏外观”(UIViewControllerBasedStatusBarAppearance) 设置为 YES。 (YES 是默认值,因此您也可以将此值保留在 plist 之外。)

关于ios - 状态栏在 iPhone 4S 上不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35702773/

相关文章:

ios - NSURLSession 线程 : Tracking multiple background downloads

ios - 如何在标签中打印数组?

ios - UICollectionViewListCell 的自定义子类中的自调整大小在 iOS 14 中不起作用

ios - 当应用程序未运行时,在后台以固定时间间隔重复调用函数

ios - SpriteKit : How to animate drawing of a rounded rectangle

ios - setStatusBarHidden :withAnimation doesn't cause subviews to auto-place correctly

ios - 如何以编程方式计算状态栏的正确文本颜色?

ios - 如何获取从 Storyboard实例化的 UIButton 类中的 View Controller 实例

iphone - 你如何阻止 UITapGestureRecognizer 捕捉每一次点击?

c# - 更新 ToolStripProgressBar 和 ToolStripStatusLabel 以及一个 Action