Nic*_*hrn 2 statusbar ios swift swift3
我已在我的文件中View controller-based status bar appearance设置为。YESInfo.plist
视图控制器(不在导航堆栈中)通过模态转场呈现。在其中,我对 Swift 3/iOS 10 进行了以下属性覆盖:
override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent }
Run Code Online (Sandbox Code Playgroud)
尽管如此,状态栏仍保留其默认(深色)样式。然而,当我打印preferredStatusBarStyle的viewDidLoad,我得到rawValue的1。检查出的文件,1指的是.lightContent。
我试图在状态栏的改变风格.lightContent,因为该视图包含UIVisualEffectView了UIBlurEffectStyle价值dark。
我做错了什么吗?
在马特的回答的帮助下,我能够解决我的问题。我必须在以下内容中使用viewDidLoad:
modalPresentationCapturesStatusBarAppearance = true
Run Code Online (Sandbox Code Playgroud)
当我尝试 matt 的解决方案时,我收到了两个编译错误:Cannot override mutable property with read-only property 'modalPresentationCapturesStatusBarAppearance'和Getter for 'modalPresentationCapturesStatusBarAppearance' with Objective-C selector 'modalPresentationCapturesStatusBarAppearance' conflicts with getter for 'modalPresentationCapturesStatusBarAppearance' from superclass 'UIViewController' with the same Objective-C selector
将其添加到模态呈现的视图控制器中:
override var modalPresentationCapturesStatusBarAppearance: Bool {
return true
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3126 次 |
| 最近记录: |