Search code examples
macoscocoaxcode-storyboardnssplitviewcontroller

NSSplitViewController causing contained views to draw over window corners


I'm trying to create a little Finder clone using Cocoa. I'm placing a source list table view (to act as a sidebar) and a standard table view inside of an NSSplitView controlled by an NSSplitViewController. Unfortunately, when I run this, the standard table view's white background is drawn over the bottom right corner of the window, resulting in a non-rounded corner: Bottom right corner drawn over

I'm able to avoid the problem by not using NSSplitViewController, both with standard nib files or storyboards to get the desired result:

Correctly drawn, albeit without NSSplitViewController

But… I really want to use NSSplitViewController. Is there any way to prevent this from happening?

Here is the Xcode workspace with the projects for the screenshots.


Solution

  • I have seen such problem and it seems to be real bug. But there is workaround for that. You need make sure NSSplitViewController renders itself in view which is backed by CA layer. So to do this in your project, I added man-in-the-middle view controller with container view. Then I placed your split view inside of this container view. Finally parent view of the container view is set to be layer backed. Here is the picture:

    enter image description here

    After that I can see everything fine:

    enter image description here

    On another note: make sure you dont use 1000 priority of constraints until it is really required. I normally use 750 (I fixed that as well). Otherwise you will get a lot warnings about unsatisfiable things.

    Here is you fixed project: https://github.com/emankovski/splitviewroundcorrners