在UIKit中,我使用以下代码以呈现带有展示样式crossDissolve的模态视图控制器。
但我如何在SwiftUI中实现这个?
controller.modalTransitionStyle = .crossDissolve
controller.modalPresentationStyle = .overFullScreen
UIApplication.topViewController()?.present(controller, animated: true, completion: nil)
但我如何在SwiftUI中实现这个?
UIViewContrller
扩展中的 Present 函数中,您可以像这样更改它:toPresent.view.backgroundColor = yourColor
。 - Mac3n@Environment(\.presentationMode) var presentationMode
,然后当你想要关闭它时,调用self.presentationMode.wrappedValue.dismiss()
。 - Mac3n@Environment(\.viewController) private var viewControllerHolder: UIViewController?
并在按钮操作中调用此代码:self.viewControllerHolder?.dismiss(animated: true, completion: nil)
。 - Mac3n