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

时间:2017-12-22 08:09:15

标签: ios objective-c uicontainerview

我有一个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的所有视图中显示?谢谢!

1 个答案:

答案 0 :(得分:0)

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