就像问题所说,当用户点击时,我需要隐藏状态栏和导航栏。到目前为止,导航栏很容易隐藏。但是找不到同样的方法来隐藏状态栏。
顺便说一下,我已经尝试过
UIApplication.sharedApplication().statusBarHidden = true
但是目前还没有成功
您应该将此键/值对添加到项目的Info.plist中。
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
之后,呼叫
UIApplication.sharedApplication().statusBarHidden = true
或者。UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .Fade) // with animation option.
这篇文章提供了更多细节 > 如何隐藏iOS状态栏
这应该能解决问题:
UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: UIStatusBarAnimation.Slide)
请参考此答案以获取更多细节。