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

问题描述 投票:0回答:1

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

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

但是仍然存在如此令人不愉快的边界。enter image description here

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

ios swift xcode uiview
1个回答
0
投票

您可以在具有透明背景的.fullscreen模式下显示新的viewController

  1. 在viewController中添加内容的视图
  2. 将自定义背景色添加到将位于顶部的viewController上的视图中,并将不透明度设置为<100%(请参见下面的屏幕截图)
  3. providesPresentationContextTransitionStyledefinesPresentationContext viewController属性设置为true
  4. 将viewController呈现样式更改为.overCurrentContext

这是您如何以编程方式进行的操作

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

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.