NSSplitViewController导致包含的视图在窗口角上绘制 [英] NSSplitViewController causing contained views to draw over window corners

查看:111
本文介绍了NSSplitViewController导致包含的视图在窗口角上绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Cocoa创建一个小的Finder克隆.我将源列表表视图(用作边栏)和标准表视图放在由NSSplitViewController控制的NSSplitView内. 不幸的是,当我运行此命令时,标准表格视图的白色背景绘制在窗口的右下角,结果是一个非圆角:

我可以通过不使用NSSplitViewController来避免此问题,无论是使用标准的笔尖文件还是情节提要,都可以得到所需的结果:

但是…我真的很想使用NSSplitViewController.有什么办法可以防止这种情况的发生?

这是包含项目的Xcode工作区查看屏幕截图.

解决方案

我已经看到了这样的问题,这似乎是真正的错误.但是有解决方法.您需要确保NSSplitViewController在由CA层支持的视图中呈现自己.因此,为了在您的项目中做到这一点,我在容器视图中添加了中间人视图控制器.然后,我将您的拆分视图放置在此容器视图的内部.最后,将容器视图的父视图设置为支持层.这是图片:

那之后,我可以看到一切正常:

另一方面,请确保不要使用1000优先级的约束,直到真正需要它为止.我通常使用750(我也固定了它).否则,您会收到很多关于不满意的警告.

这是您固定的项目: https://github.com/emankovski/splitviewroundcorrners

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:

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

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.

解决方案

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:

After that I can see everything fine:

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

这篇关于NSSplitViewController导致包含的视图在窗口角上绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆