iOS昏暗背景全屏查看 [英] iOS dim background View full screen

查看:50
本文介绍了iOS昏暗背景全屏查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题应该很简单,但是我找不到解决方法.

My question should be simple but I couldn't find solution.

我正在显示模式VC,我想附加暗淡的背景视图.

I am displaying modal VC and I want to append dim background view.

模态VC作为子级添加到父级VC.父VC放置在导航控制器( topViewController )

Modal VC is added as a child to the parent VC. Parent VC is placed at top of Navigation Controller (topViewController)

Dim视图已添加到 UIScreen.windows.first!窗口.但是,暗淡的视图无法覆盖整个屏幕.我确实使用 CGPointZero 为其设置了框架,我尝试了负y值,但没有帮助.看起来就像这样.我还添加了一组自动布局约束,设置为false/true translatesAutoresizingMaskIntoConstraints 属性,更改了 clipToBounds .

Dim view is added to the UIScreen.windows.first! window. But the dim view doesn't fill the whole screen. I do set frame for it with CGPointZero for origin, I tried negative y value it didn't help. It just look like this. Also I added set of auto layout constraints, set to false/true translatesAutoresizingMaskIntoConstraints property, changed clipToBounds.

没有帮助,昏暗的视图无法覆盖整个屏幕.

Nothing helps, the dim view doesn't cover entire screen.

如果不将模式VC作为子级添加,我可以全屏显示暗淡的视图,即我直接利用模式VC的视图,并将其添加到 window 中.看起来不错,但是还有另一个错误.这就是为什么我要添加模态VC作为子级VC的原因.如何强制变暗视图显示整个屏幕.

I can display the dim view in full screen, if I don't add modal VC as a child, i.e. I directly utilize modal VC's view, and add it to the window. It looks fine, but there is another bug. That's why I am adding modal VC, as a child VC. How to force dim view display the whole screen.

在该应用中,可能会同时显示多个模态VC,这就是为什么序号(即VC呈现)不是最佳选择的原因.

In the app there might be several modal VC displayed simultaneously, that's why seques, (i.e presentation of VCs) is not the best choice.

P.S.这是该错误的描述:

P.S. Here is description of the bug :

.如果将模态VC(将UITableVC放置在导航控制器中)直接添加到窗口中,则从BG返回后,即在BG中并开始从BG开始显示模态VC之后,视图将显示已移动的表.切换回前台,表格标题的一部分(问题已显示部分)被上移,并且模式VC的导航栏被展开,即它们相交,表格标题没有完全显示.我无法解决.

. In case of adding modal VC (UITableVC placed into Nav. Controller)'s view directly to the window , view displays shifted table, after returning back from BG, i.e. in case of being in BG and starting to display modal VC from BG, after that switching back to Foreground, part of table's header (Question is revealed part) is shifted up and modal VC's navigation bar is expanded, i.e. they intersect, header of the table isn't display completely. I couldn't fix that.

推荐答案

将视图放置在导航控制器的视图下:

Put your view under navigation controller's view:

UIView *dimView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
dimView.backgroundColor = [UIColor colorWithWhite:.4f alpha:.5f];
[self.navigationController.view addSubview:dimView];
[self.navigationController.view bringSubviewToFront:dimView];

这篇关于iOS昏暗背景全屏查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆