struct BlurView: NSViewRepresentable {
func makeNSView(context: Context) -> NSVisualEffectView {
let blurView = NSVisualEffectView(frame: NSRect(x: 0, y: 0, width: 100, height: 100))
blurView.blendingMode = NSVisualEffectView.BlendingMode.behindWindow
blurView.material = NSVisualEffectView.Material.hudWindow
blurView.isEmphasized = true
blurView.state = NSVisualEffectView.State.active
return blurView;
}
func updateNSView(_ nsView: NSVisualEffectView, context: Context) {
NSLog("updateNSView")
}
func test() -> some View {
NSLog("Test")
return self
}
};
struct ContentView: View {
var body: some View {
Button(action: {}, label: {
Image(systemName: "sidebar.leading")
Text("更改")
})//.frame(width: 300, height: 300, alignment: .topLeading)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.frame(minWidth: 300, minHeight: 300)
.background(BlurView().test())
.ignoresSafeArea()
}
}
image.png