4

There's my code:

var newBut = NSButton(frame: NSRect(x: 150, y: 200, width: 30, height: 30))
newBut.title = "press me!"
self.view.addSubview(newBut)

But it creates the button that differs from square button. It's darker and has smh like a shadow. I'm looking for a way to change its appearance to copy the square button style.

2 Answers2

5

Just set the bezelStyle of your NSButton to SmallSquareBezelStyle.

newBut.bezelStyle = NSBezelStyle.SmallSquareBezelStyle
Christian
  • 22,585
  • 9
  • 80
  • 106
1

In Swift 4 (Xcode 9) "bezelStyle" is now "BezelStyle".

Note that, BezelStyle no longer has a member "SmallSquareBezelStyle". BezelStyle is a "UInt".

Per Apple "NSButton.BezelStyle" documentation, BezelStyle can be:

  • circular
  • disclosure
  • helpButton
  • inLine
  • recessed
  • regularSquare
  • roundRect
  • rounded
  • roundedDisclosure
  • shadowlessSquare
  • smallSquare
  • textureRounded, and
  • texturedSquare

It seems that you were looking at one of the "square" button cases.

Vic W.
  • 817
  • 1
  • 7
  • 9