title: Creating a custom title bar on a standard NSWindow
body: <p>I've been trying to build a specific look for my menubar app.</p>
  
  <p><img src="https://i.stack.imgur.com/cJSJ5.png" alt="enter image description here"></p>
  
  <p>I've been using a <code>NSWindow</code> with a <code>NSBorderlessWindowMask</code> style mask and setting <code>[window setOpaque:NO]</code> and <code>[window setBackgroundColor:[NSColor clearColor]]</code>. That gives me a blank canvas which works great for the title bar.</p>
  
  <p>Now I'm having problems with the view-based <code>NSTableView</code> I'm using for the listing. How can I clip the <code>NSTableCellView</code>s to the window's rounded corners?</p>
  
  <p>I started out just having a custom view wrapping the <code>NSTableView</code>, drawing the background with rounded corners. Using <code>[view addClip:path]</code> doesn't clip child views though.</p>
  
  <p>I've also tried using a <code>[view setWantsLayer:YES]</code> with a mask. That worked great, but the table view cells would sporadically glitch out. It seems that having a <code>NSScrollView</code> be a child of a layer is a known problem:</p>
  
  <p><img src="https://i.stack.imgur.com/OLcHx.png" alt="http://i.stack.imgur.com/JmhjD.png"></p>
  
  <p>My current view structure looks something like:</p>
  
  <pre><code>NSWindow
  - MyTitleBarView
  - MyBackgroundView
    - NSScrollView
      - NSTableView
  </code></pre>