如何在Swift 3中设置状态栏样式 [英] How to set Status Bar Style in Swift 3

查看:166
本文介绍了如何在Swift 3中设置状态栏样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 8.0 beta 4.



在以前的版本中,UIViewController有方法设置状态栏样式

  public func preferredStatusBarStyle() - > UIStatusBarStyle 

然而,我发现它在Swift 3中改为Get ONLY varaiable。

  public var preferredStatusBarStyle:UIStatusBarStyle {get} 

如何提供在我的UIViewController中使用的样式?

解决方案

iOS 11和Swift 4,Xcode 9 (也适用于iOS 10和Swift 3)


  1. 更改 info.plist
    查看基于控制器的状态栏外观并将其设置为


  2. didFinishLaunchingWithOptions

    b
    $ UIApplication.shared.statusBarStyle = .lightContent



I'm using Xcode 8.0 beta 4.

In previous version, UIViewController have method to set the status bar style

public func preferredStatusBarStyle() -> UIStatusBarStyle

However, I found it changed to a "Get ONLY varaiable" in Swift 3.

public var preferredStatusBarStyle: UIStatusBarStyle { get } 

How can provide the style to use in my UIViewController?

解决方案

iOS 11 and Swift 4, Xcode 9 (Also works fine with iOS 10 and Swift 3)

  1. Change in info.plist the row View controller-based status bar appearance and set it to NO

  2. Change in appDelegate.swift in didFinishLaunchingWithOptions

    UIApplication.shared.statusBarStyle = .lightContent
    

这篇关于如何在Swift 3中设置状态栏样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆