ios - 透明 subview Controller 的 View

标签 ios uiview uiviewcontroller

我正在父 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/

相关文章:

ios - 带有 UITableViewController 的 SearchBar 包含错误数量的单元格

ios - UITableViewCell 掩码选择区域/选择区域的大小?

iPhone - 创建一个带有不透明文本的半透明矩形

iphone - 对于 UIViewController 哪些方法应该是 "release"并将导出/实例变量设置为 "nil"?

objective-c - 如何确定 tabbarcontroller 中的当前事件 View

ios sdk 停止多点触控功能

ios - 在 Swift 中将图层样式组合到多个 UIButton

ios - 使用 UIViewAnimationTransitionFlipFromRight 在按下时翻转 UIButton 并在 "the other side"上显示新按钮

iOS 导航栏 VS UIToolBar

objective-c - 如何检查当前加载的 View Controller ? (ObjC + swift )