How to hide the status bar programmatically in iOS 8 [duplicate]

左心房为你撑大大i 提交于 2019-12-10 13:44:48

问题


Just like the question says, I need to hide status + navigation bar when user taps. So far, navigation bar was easy. Cann't find a way to do the same with status bar.

By the way, tried

UIApplication.sharedApplication().statusBarHidden = true

but no luck yet


回答1:


You should add this key/value pair to your project's Info.plist.

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

After that,calling

UIApplication.sharedApplication().statusBarHidden = true

or

UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .Fade) // with animation option.

This post gives more details > How to hide iOS status bar




回答2:


This should do the trick:

UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: UIStatusBarAnimation.Slide)

See this answer for more details.



来源:https://stackoverflow.com/questions/30271271/how-to-hide-the-status-bar-programmatically-in-ios-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!