英文:
How to hide the StatusBar in iOS13?
问题
在iOS 13之前,我通过来获取状态栏。但在iOS 13上会崩溃。所以在iOS 13中有没有获取状态栏的方法?或者有没有其他方法来满足我的需求。
英文:
I want to customize a toast view which needs to hide the status bar. Before iOS 13, I get the status bar by .
But in iOS 13 it will crash. So is there some ways to get the status bar in iOS 13?
Or does anybody know other ways to solve my demand.
答案1
得分: 1
-(BOOL)prefersStatusBarHidden {
return true;
}
使用这个方法。
英文:
-(BOOL)prefersStatusBarHidden {
return true;
}
Use this method.
答案2
得分: 0
将以下内容添加到info.plist文件中(在源代码模式下打开):
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
英文:
Add this in info.plist file (open it in source mode):
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
答案3
得分: 0
如果您想在不同的iOS 13视图控制器上隐藏/显示状态栏,您需要执行以下操作:
- 在您的 Info.plist 中添加 View controller-base status bar appearance 选项,并将其设置为YES。
- 在每个您想要显示/隐藏状态栏的视图控制器中,重写 var prefersStatusBarHidden: Bool。
有关更多详细信息,请参考此答案:链接。
英文:
If you want to hide/show status bar on the different view controllers for iOS 13 then you need to do this :
- Add View controller-base status bar appearance option in your
Info.plist and set it to YES - Override var prefersStatusBarHidden: Bool in each View Controller
where you want to have the status bar shown/hidden
Refer this answer for more information in a detail.
答案4
得分: 0
尝试这样做:
UIApplication.sharedApplication.statusBarHidden = true;
英文:
Try this :
UIApplication.sharedApplication.statusBarHidden = true;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论