我跟着这个线程来覆盖-preferredStatusBarStyle,但它没有被调用.我可以更改任何选项以启用它吗?(我在我的项目中使用XIB.)
我正在使用Xcode 8.0 beta 4.
在以前的版本中,UIViewController具有设置状态栏样式的方法
public func preferredStatusBarStyle() -> UIStatusBarStyle
Run Code Online (Sandbox Code Playgroud)
但是,我发现它在Swift 3中改为"Get ONLY varaiable".
public var preferredStatusBarStyle: UIStatusBarStyle { get }
Run Code Online (Sandbox Code Playgroud)
如何在我的UIViewController中提供使用的样式?
我正在编写一个包含多个视图的iOS应用程序.我已经将App设置为使用基于ViewController的状态栏样式,这允许我使用以下代码
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
Run Code Online (Sandbox Code Playgroud)
这有点像预期的那样.
但后来我在导航控制器中嵌入了视图,并将BarButtonItem与showSegue连接起来.从那时起,视图的ViewController切换为忽略样式设置并显示默认的黑色状态栏.