首先添加一个UIView

首先添加一个UIView

本文介绍了首先添加一个UIView,甚至是导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在任何其他视图之上显示甚至是导航栏,这是一种pop-up视图,如下所示:

I want to display, above any other views, even the navigation bar, a kind of "pop-up" view that looks like this:


  • 全屏黑色背景,0.5 alpha,看到另一个 UIViewController 下面。

  • a UIView 中间带有一些信息的窗口,(如果你想了解所有内容,则为日历)。

  • full screen black background with a 0.5 alpha to see the other UIViewController underneath.
  • a UIView window in the middle with some information, (a calendar if you want to know everything).

为此,我创建了一个包含两个 UIViews (背景和窗口)的UIViewController,我正在尝试显示它。我尝试过一个简单的 [mySuperVC addSubview:myPopUpVC.view] ,但我仍然有上面的导航栏。

To do that, I've created a UIViewController that contains the two UIViews (background and window), and I'm trying to display it. I've tried a simple [mySuperVC addSubview:myPopUpVC.view], but I still have the navigation bar above.

我试图将它作为模态呈现,但下面的 UIViewController 消失了,我失去了透明效果。

I've tried to present it as a modal, but the UIViewController underneath disappears, and I lose my transparency effect.

任何想法都这样做,我相信这很简单...

Any idea to do this, I'm sure it's quite simple...

谢谢!

推荐答案

您可以通过将视图直接添加到keyWindow来实现:

You can do that by adding your view directly to the keyWindow:

UIView *myView = /* <- Your custom view */;
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
[currentWindow addSubview:myView];

这篇关于首先添加一个UIView,甚至是导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:44