我想知道是否可以在其 subview Controller 的 View 之一上设置 View Controller 的 View ?
让我们用一个例子来解释:
假设我有两个 UIViewController
:parentVC
和 childVC
。 childVC
是 parentVC
的 child 。
现在,我有一个 UIButton
(称为 button
),它是 parentVC.view
的 subview 。
我像这样从 parentVC
设置 childVC
:
self.addChildViewController(childVC)
childVC.didMoveToParentViewController(self)
childVC.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height
self.view.addSubview(childVC.view)
现在,即使 childVC.view
覆盖了 parentVC.view
,我也希望 button
显示。
你们认为有办法做到这一点吗?我试着玩 button.layer.zPosition
但我没能成功。
最佳答案
是的,你可以,你只需要将按钮添加到 View 层次结构中,或者在添加 subview Controller 后将按钮在层次结构中向上移动。
关于ios - 如何在 subview Controller 的 View 上设置 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37389079/