NSView not transparent in a transparent window

(Swift, macOS, storyboards.)

I have a window that is semitransparent and a NSView that I want to be not transparent or with a different transparent degree.

With my code, if I make the window transparent the NSView is also transparent.

func finestra() {
    self.view.window?.alphaValue = 0.7
}

func nsView1() {
    nsViewOutlet.wantsLayer = true
    nsViewOutlet.layer?.backgroundColor = NSColor.white.cgColor
    nsViewOutlet.alphaValue = 1
}