使用源列表样式向 NSOutlineView 添加自定义子视图
我想在设置了 NSTableViewSelectionHighlightStyleSourceList
的 NSOutlineView
内容上方添加一些控件,使其看起来像 Finder/iTunes/iPhoto 之类的源列表。因此,我要添加的控件应放置在整个源列表上方,但与大纲视图位于同一 NSScrollView
中。它们后面的颜色也应该是源 lis 的颜色(这很特殊,因为当窗口失去焦点时它会从浅蓝色变为灰色)。
我已经尝试以编程方式将 NSOutlineView
在其父视图(即 NSClipView
和 NSScrollView
)内向下移动,但是更改了 >NSOutlineView
s 框架不起作用(框架根本没有改变)。
干杯
法师先生
I'd like to add some controls above the contents of an NSOutlineView
that has NSTableViewSelectionHighlightStyleSourceList
set so that it looks like a Finder/iTunes/iPhoto-like source list. The controls I want to add should therefore be placed above the whole source list, but in the same NSScrollView
as the outline view. The color behind them should also be that of the source lis (which is special because it changes from light blue to grey when the window loses focus).
I already tried to move the NSOutlineView
down programmatically inside its parent views (which are a NSClipView
and then an NSScrollView
), but changing the NSOutlineView
s frame doesn't work (the frame isn't changed at all).
Cheers
MrMage
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所描述的控件共享源列表的背景颜色,但高于内容(上方,而不是顶部),与 Finder 或 iTunes 完全不同。他们将控件放在窗口的工具栏空间中。事实上,您所描述的听起来完全是一个糟糕的 UI 决策。
也就是说,您可能可以通过添加一行或多行“空内容”来实现您的既定目标,即从
outlineView:objectValueForTableColumn:byItem: 返回
nil
并可能设置自定义行height 与outlineView:heightOfRowByItem:
,然后将子视图添加到该“空”空间中。What you're describing -- controls sharing the background color of a source list but higher than (above, not on-top of) the content -- is not at all similar to Finder or iTunes. They put controls in the window's toolbar space. In fact, what you describe sounds like a poor UI decision entirely.
That said, you could probably achieve your stated goal by adding one or more rows of "empty content" i.e. return
nil
fromoutlineView:objectValueForTableColumn:byItem:
and possibly set custom row height withoutlineView:heightOfRowByItem:
and then add your subviews onto that "empty" space.