Make iPhone status bar disappear when displaying a modal view?(显示模态视图时使 iPhone 状态栏消失?)
问题描述
我想显示一个模态视图,并希望它覆盖 iPhone 的状态栏.
I want to display a modal view, and want it to cover the iPhone's status bar.
我尝试将模态视图控制器的 WantsFullScreenLayout 属性设置为 YES;我还将其父级的属性也设置为 YES.这不起作用,大概是因为模态视图显示在主窗口内容下方,其中包括状态栏.
I tried setting the modal view controller's wantsFullScreenLayout property to YES; I also set its parent's property to YES as well. This doesn't work, presumably because the modal view displays below the main window's content, which includes the status bar.
我的第二种方法放弃了整个wantsFullScreenLayout"技术,转而在模态视图显示之前隐藏状态栏,然后在模态视图关闭后将其重新打开.这一直有效...模式视图的父视图布局不正确(其导航栏部分隐藏在状态栏后面.)调用 -[view setNeedsLayout] 什么都不做.
My second approach dropped the whole "wantsFullScreenLayout" technique in favor of hiding the status bar just before the modal view is displayed, then turning it back on after the modal view is dismissed. This works until the very end...the modal view's parent view is laid out incorrectly (its navigation bar is partially hidden behind the status bar.) Calling -[view setNeedsLayout] does nothing.
我应该如何解决这个问题?
How should I approach this problem?
谢谢.
推荐答案
你会想要 - (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated
在 >UIApplication
类.
You'll be wanting the - (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated
on the UIApplication
class.
类似这样的:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
这应该用漂亮的淡入淡出动画隐藏状态栏.
That should hide the status bar with a nice fade animation.
这篇关于显示模态视图时使 iPhone 状态栏消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:显示模态视图时使 iPhone 状态栏消失?


基础教程推荐
- :hover 状态不会在 iOS 上结束 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01