NSProgressIndicator 透明背景的设置

4
无法使NSProgressIndicator具有透明的背景,无论如何它都显示为灰色背景:
let progressbar = NSProgressIndicator.init(frame: NSRect(x: 10, y: y+4, width: 60, height: 60))
progressbar.style = NSProgressIndicatorStyle.SpinningStyle
progressbar.controlTint = NSControlTint.ClearControlTint
progressbar.wantsLayer = true
progressbar.layer?.backgroundColor = NSColor.clearColor().CGColor
self.contentView.addSubview(progressbar)

有什么想法吗?
2个回答

0

我知道这已经晚了3年,也许你已经得到答案了,但是这里是答案。

progressbar.appearance = NSAppearance(named: NSAppearance.Name.aqua)

-1
尝试将 wantsLayer = true 设置为窗口本身(以及可能是内容视图)。

我从未见过需要设置:progressbar.controlTint = NSControlTint.ClearControlTint progressbar.wantsLayer = true progressbar.layer?.backgroundColor = NSColor.clearColor().CGColor的情况。当你使用IB时,你只需将该元素拖放到所需控件的表面上,它就具有透明背景。有时候会遇到CI层的问题,那么你要设置其父级拥有图层。很抱歉我无法帮助你... - Eugene Mankovski

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接