You need visual effect view in background (it is used by default for sidebar styled lists)
Demo prepared & tested with Xcode 11.4 / macOS 10.15.6
struct VisualEffectView: NSViewRepresentable {
func makeNSView(context: Context) -> NSVisualEffectView {
let view = NSVisualEffectView()
view.blendingMode = .behindWindow // << important !!
view.isEmphasized = true
view.material = .appearanceBased
return view
}
func updateNSView(_ nsView: NSVisualEffectView, context: Context) {
}
}
and put it to needed area, in this case below TextField
TextField("Username", text: $username)
.padding(.leading, 20)
.padding(.trailing, 20)
.background(
RoundedRectangle(cornerRadius: 5)
.fill(Color.white.opacity(0.3)
)
.padding(.leading, 20)
.padding(.trailing, 20)
)
.padding(.top)
.padding(.bottom)
.background(VisualEffectView())
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…