Swift 4中的statusBarStyle

Win*_*ngs 3 statusbar uinavigationbar ios swift

这是我在AppDelegate类(Swift 4)中编写的代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
     UIApplication.shared.statusBarStyle = .lightContent
    goToRootViewController()
    UINavigationBar.appearance().isTranslucent = true

    UINavigationBar.appearance().shadowImage = UIImage()
    UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
    GMSServices.provideAPIKey(googleMapApiKey)
    return true
}
Run Code Online (Sandbox Code Playgroud)

但我的状态栏没有显示轻量级内容我不知道什么是ging,任何帮助?

Inc*_*Dev 13

对于特定的ViewController类:

在viewcontroller类中,使用viewDidLoad()下面的代码:

override var preferredStatusBarStyle : UIStatusBarStyle {
    return .lightContent
}
Run Code Online (Sandbox Code Playgroud)

这将在轻量级内容中显示您的状态栏

适用于整个应用:

在产品的Info.plist中设置"查看基于控制器的状态栏外观"键,其值为"NO"

在此输入图像描述

然后在"didFinishLaunchingWithOptions"中的AppDelegate.Swift中使用以下代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    UIApplication.shared.statusBarStyle = .lightContent
    return true
}
Run Code Online (Sandbox Code Playgroud)