【发布时间】:2023-01-07 10:07:17
【问题描述】:
我尝试将 VStack 嵌入到另一个带有 .background(.gray.opacity(90)) 的 VStack 中,但它没有做任何事情。我正在使用fullScreenCover:
let width = UIScreen.main.bounds.width
.fullScreenCover(isPresented: $showCover) {
BuyWithPointsView(type: type).frame(width: (width * (91.733 / 100)), height: (width * (66.667 / 100)))
}
编辑: 我尝试实现这个答案:SwiftUI: Translucent background for fullScreenCover
.fullScreenCover(isPresented: $showCover) {
ZStack {
ZStack {
Color.gray.opacity(0.1).edgesIgnoringSafeArea(.all)
}.background(BackgroundBlurView())
BuyWithPointsView(type: type).frame(width: (width * (91.733 / 100)), height: (width * (66.667 / 100)))
}
}
struct BackgroundBlurView: UIViewRepresentable {
func makeUIView(context: Context) -> UIView {
let view = UIVisualEffectView(effect: UIBlurEffect(style: .light))
DispatchQueue.main.async {
view.superview?.superview?.backgroundColor = .clear
}
return view
}
func updateUIView(_ uiView: UIView, context: Context) {}
}
【问题讨论】: