我正在父 View Controller 中创建一个 subview Controller ,并使用下面的代码呈现它 -
self.addChildViewController(childVC)
childVC.view.frame = self.view.bounds
self.view.addSubview(childVC.view)
childVC.view.autoresizingMask = [.flexibleWidth,.flexibleHeight]
childVC.didMove(toParentViewController: baseVC)
subview Controller 只是在中间显示一个 200 X 300 的 ImageView 。我希望 subview Controller 模糊父 View Controller 的 View 并显示这个不透明的 ImageView 。但是,无论我做什么,我似乎都无法让它显示底层父 View Controller 的内容。我已经在 subview Controller 的 viewDidLoad 中尝试了以下操作 -
view.backgroundColor = UIColor.black.withAlphaComponent(0.5)
我在这里想念什么?有更好的方法吗? subview Controller 的目的是通过模糊父 View Controller 的内容来封装图像预览逻辑,并在其 View 的中心显示一个 UIImageView。
最佳答案
尝试使用 ChildVC.backgroundColor = UIColor.black.withAlphaComponent(0.5)。此代码使 subview 显示为半透明。
希望这可以帮助。
关于ios - 透明 subview Controller 的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47899539/