从 NSButton 移除背景

Eli*_*Eli 7 nsbutton swift

嘿,所以我有一个嵌入在视觉效果视图中的表格视图,在其中一行中,我有一个保存按钮,每次单击单元格时保存按钮都会在它周围获得这种时髦的背景颜色。 在此处输入图片说明

我试过了

saveButton.wantsLayer = true
saveButton.layer?.backgroundColor = NSColor.clearColor.CGColor
Run Code Online (Sandbox Code Playgroud)

但这不起作用,在标签和东西之类的事情上发生了同样的事情,但我能够通过将背景颜色设置为一种颜色然后一直降低不透明度来修复它。但是因为它的按钮不起作用!有任何想法吗?

MCM*_*tan 3

如果有人仍然陷入困境,似乎设置isBordered可以false解决问题。

saveButton.wantsLayer = true
saveButton.layer?.backgroundColor = NSColor.clearColor.CGColor

saveButton.isBordered = false // This does the trick.
Run Code Online (Sandbox Code Playgroud)