Search code examples
swiftmacosnsbutton

Swift 3 macOS, set default button style


When I create a new NSButton, how can I set it's style to the Default one?

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])

Style I want to have:

button with default style

Current Style:

button with current style


Solution

  • You should change the button's bezelStyle to rounded, e.g.:

    nomplusbut.bezelStyle = .rounded