如何从容器视图中添加占用所有视图的视图?

问题描述 投票:0回答:1

我有一个UIContainerVIew。从这里,我想在所有viewController中加载一个具有不透明度的UIView。

float width = [[UIScreen mainScreen] bounds].size.width;
float height = [[UIScreen mainScreen] bounds].size.height;

self.myView = [[ITSMyView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, width, height)];
[self.myView setFrame:CGRectMake(self.view.superview.superview.frame.origin.x, self.view.superview.superview.frame.origin.y, width, height)];

[self.view addSubview:self.myView];

如何正确添加并在UIContainerView的所有视图中显示?谢谢!

ios objective-c uicontainerview
1个回答
0
投票

你可以使用 for (UIViewController * vc in self.parent.childViewControllers) { vc.view.addSubView(viewtoAdd) }

© www.soinside.com 2019 - 2024. All rights reserved.