Is it possible to make a circular NSButton?
<p>I am trying to create a custom shape <code>NSButton</code>. In particular I am trying to make a round button, using a custom image. I've found <a href="http://www.iosinsight.com/circular-uibutton-with-swift/" rel="noreferrer">a tutorial</a> on the creation of custom <code>UIButton</code> and tried to adapt it to NSButton. But there's a huge problem. <code>clipsToBounds</code> seems to be iOS only(</p>

<p>Here's my code:</p>

<pre><code>import Cocoa

class ViewController: NSViewController {

    @IBOutlet weak var mainButton: NSButton!
    var size = 32

    override func viewDidLoad() {
        super.viewDidLoad()
        configureButton()
                // Do any additional setup after loading the view.
    }
    func configureButton()
    {
        mainButton.wantsLayer = true
        mainButton.layerContentsRedrawPolicy = NSViewLayerContentsRedrawPolicy.OnSetNeedsDisplay
        mainButton.layer?.cornerRadius = 0.5 * mainButton.bounds.size.width
        mainButton.layer?.borderColor = NSColor(red:0.0/255.0, green:122.0/255.0, blue:255.0/255.0, alpha:1).CGColor as CGColorRef
        mainButton.layer?.borderWidth = 2.0
    }

    override var representedObject: AnyObject? {
        didSet {
        // Update the view, if already loaded.
        }
    }


}
</code></pre>

<p>What am I doing wrong? How can I make a circular NSButton? Can you suggest anything on replacing <code>clipsToBounds</code>?</p>

<p>Because here is what I was able to get so far:</p>

<p><a href="https://i.stack.imgur.com/acPBk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/acPBk.png" alt="enter image description here"></a></p>