Swift 3 macOS,设置默认按钮样式

问题描述 投票:0回答:1

当我创建一个新的NSButton时,如何将它的样式设置为默认样式?

let (nomplusbut) = NSButton(frame: CGRect(x: 200, y: iy, width: 300, height: 40))
(nomplusbut).title = "Pfad öffnen..."
(nomplusbut).target = (self, action: #selector(buttonAction)) as AnyObject?
(nomplusbut).isBordered = true
(nomplusbut).setButtonType(NSMomentaryPushInButton)

arraybut.append(nomplusbut)

print(array[array.count - 1].stringValue)
self.view.addSubview(arraybut[arraybut.count - 1])

我希望拥有的风格:

button with default style

当前风格:

button with current style

swift macos nsbutton
1个回答
0
投票

您应该将按钮的bezelStyle更改为rounded,例如:

nomplusbut.bezelStyle = .rounded
© www.soinside.com 2019 - 2024. All rights reserved.