Hey everyone,
I’m facing a bug when using UIVisualEffectView
in a SwiftUI context via UIViewRepresentable
. When the SwiftUI view modifier .blur(radius: xx, opaque: true)
is applied to it during rotation, the blur effect isn’t applied. Instead, the view becomes completely white or black, depending on the UIBlurEffect.Style
applied to the UIVisualEffectView
.
I’m not sure how to proceed with this issue and am seeking your help. Below is a simple, reproducible piece of code:
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
Circle()
.fill(.pink)
GlassBackgroundView()
.blur(radius: 7, opaque: true)
}
.ignoresSafeArea()
}
}
#Preview {
ContentView()
}
private struct GlassBackgroundView: UIViewRepresentable {
func makeUIView(context: Context) -> UIVisualEffectView {
UIVisualEffectView(effect: UIBlurEffect(style: .regular))
}
func updateUIView(_ uiView: UIVisualEffectView, context: Context) { }
}