1

I am trying to use the NSVisualEffectView in my project with SwiftUI. This is how I imported it:

struct VisualEffectView: NSViewRepresentable {
  func makeNSView(context: Context) -> NSVisualEffectView {
    let view = NSVisualEffectView()
    view.blendingMode = .withinWindow
    view.isEmphasized = true
    view.material = .sidebar
    return view
  }

  func updateNSView(_ nsView: NSVisualEffectView, context: Context) {

  }
}

Then this is how I am using it

var body: some View {
  ZStack {
    Image("someImage")
    SomeText()
      .background(VisualEffectView())
  }
}

Eventually, it showed up on the screen as a box grey box without translucent or blur. Anyone know what I am missing from the example above? Thank you for your help

WatashiJ
  • 722
  • 6
  • 19
  • This looks like a bug in SwiftUI resulting from visual effect view sizing, because if you put your `VisualEffectView` just above Image, then all works. It worth submitting feedback to Apple. – Asperi Jun 21 '20 at 04:49

0 Answers0