[英]How to make a UIView that can cover the navigation bar?
I want to show the UIView
in full screen, but show the status bar, other things, like the navigation bar need to cover by the UIView
. 我想全屏显示
UIView
,但显示状态栏,其他内容,例如导航栏,都需要由UIView
覆盖。
How can I do that ? 我怎样才能做到这一点 ?
I believe what he was asking was how to make a UIView cover the entire screen (sort of like custom pop up). 我相信他在问的是如何使UIView覆盖整个屏幕(有点像自定义弹出窗口)。 This is precisely how I ended up here.
这正是我最终到这里的方式。 So I will offer my solution.
因此,我将提供我的解决方案。 Call this function anywhere.
在任何地方调用此函数。
[self.navigationController.view addSubview:yourUIView];
Here the view you introduced cover over the whole screen unlike 在这里,您介绍的视图覆盖了整个屏幕,
[self.view addSubview:yourUIView];
Whereby, the navigation bar is uncovered. 从而,导航栏被发现。
将视图直接作为子视图添加到主UIWindow实例。
Struggling a little to fully understand the question, but I think you're asking how you can display a UIView
above another view (so that the view with the navigation controls is completely hidden by the second view)? 努力一点来完全理解这个问题,但是我想您是在问如何在另一个视图上方显示
UIView
(以便带有导航控件的视图被第二个视图完全隐藏)?
UIViewController
has: UIViewController
具有:
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
It would be wise to have your second view managed by a UIViewController
, too. 也可以通过
UIViewController
管理第二个视图。 For the sake of example let's say your view with the navigation bar is managed by UINavigationViewController
, and the view you want to display is managed by otherViewController
... 举个例子,假设带有导航栏的视图由
UINavigationViewController
管理,而要显示的视图由otherViewController
管理...
[navigationViewController presentModalViewController:otherViewController animated:YES];
I know the OP was looking for a way to cover the navigation bar totally, but instead of covering it, you could just temporarily hide it. 我知道OP正在寻找一种完全覆盖导航栏的方法,但是除了覆盖它之外,您还可以临时隐藏它。 Once hidden, you can add you view as a subView and change its frame or constraints so it takes up the whole screen.
隐藏后,您可以将视图添加为子视图,并更改其框架或约束,使其占据整个屏幕。
- (void)showViewOverNavBar:(UIView *)view {
[self.navigationController setNavigationBarHidden:YES];
[self.view addSubview:view];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.