I am trying to make a form that is transparent. The only way I found to do this, is to use a NSVisualEffectsView (see code below).
My problem is that I want the view to behave like a normal SwiftUI container (for example a Form), and that it takes the size of its children. I want the resulting window to take the size defined by the children, in this case the "Hallo World" Text view.
How do I do this?
import SwiftUI
struct EffectsView: NSViewRepresentable {
func makeNSView(context: Context) -> NSVisualEffectView {
return NSVisualEffectView()
}
func updateNSView(_ nsView: NSVisualEffectView, context: Context) {
// Nothing to do.
}
}
struct ContentView: View {
var body: some View {
ZStack {
EffectsView()
Text("Hallo World")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}