My question should be simple but I couldn't find solution.
I am displaying modal VC and I want to append dim background view.
Modal VC is added as a child to the parent VC. Parent VC is placed at top of Navigation Controller (topViewController
)
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.
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.
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. Here is description of the bug :
. 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];