There is a much easier way to do this. I've read that you can change a window's appearance to "textured" in a Storyboard / .xib file, but that doesn't work completely (titlebar color is mottled). However, you can change the color in your code with only two lines:
window.titlebarAppearsTransparent = true // gives it "flat" look
window.backgroundColor = <NSColor> // set the background color
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…