如何在呈现后隐藏视图的阴影?

How to hide view's shadow after its presenting?

我想从 table 单元格调用具有透明背景的 UIView。

let myView = MyViewController()
myView.view.backgroundColor = .clear
tableController.present(myView, animated: true, completion: nil)

可是,这样不愉快的境界,却一直存在。

myView.modalPresentationStyle = .fullScreen 更糟 - 删除背景视图。

您可以在具有透明背景的全屏(或任何其他)模式下展示新的 viewController

  1. 添加包含内容的视图 viewController
  2. 向 viewController 主视图添加自定义背景颜色。将 opacity 设置为小于 100% 的任何值(例如 30% - 请参见下面的屏幕)
  3. 将viewController的演示风格更改为.overCurrentContext

以下是您如何以编程方式执行此操作

//apply that for viewController that will be displayed at the top
viewController.modalPresentationStyle = .fullScreen
viewController.modalPresentationStyle = .overCurrentContext