简体   繁体   English

创建类似Xcode的Outline View标题

[英]Create Xcode-like Outline View header

OK, this what I'm trying to replicate : 好的,这就是我想要复制的内容:

在此输入图像描述

I suppose that is an NSOutlineView - a "Source List"-type one actually. 我想这是一个NSOutlineView实际上是一个“源列表”类型。 I'm used to be working with NSOutlineView s with ImageAndTextCell . 我曾经和ImageAndTextCell一起使用NSOutlineView

  • Is it a view-based NSOutlineView or should I still use ImageAndTextCell ? 它是基于视图的NSOutlineView还是我还应该使用ImageAndTextCell
  • How am I to draw a different background for this specific "Header" element? 我如何为这个特定的“标题”元素绘制不同的背景?
  • How would you go about it? 你会怎么做?

How about using a view-based NSTableView and returning different views for the header and item rows (let's call them..)? 如何使用基于视图的NSTableView并为标题项目行返回不同的视图(让我们称之为..)?

I suppose you could have a NSTableViewDelegate that would depending on what type is required return from its tableView:viewForTableColumn:row: method either a header-type or item-type view prototype depending on the row (index)? 我想你可以有一个NSTableViewDelegate ,它取决于从tableView:viewForTableColumn:row:返回所需的类型tableView:viewForTableColumn:row:方法是一个header-type或item-type view prototype取决于行(index)?

Not sure if views returned by that method are allowed to have different heights or if you've got to handle that separately. 不确定该方法返回的视图是否允许具有不同的高度,或者您是否必须单独处理它。 If view-based table views are not smart enough to do it on their own you might have to implement - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row as well to set row heights appropriately for headers/items. 如果基于视图的表视图不够智能而无法独立完成,则可能必须实现- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row以适当地设置标题/项的行高。

Use aa NSTabView without the tabs for the content, for the buttons just use NSButtons but with no background only your image for the entire cell and set them up as radio button, make sure they are in a NSMatrix. 使用没有内容选项卡的NSTabView,因为按钮只使用NSButton但没有背景只有整个单元格的图像并将它们设置为单选按钮,确保它们位于NSMatrix中。 You can then use NSOutlineView inside you tab view panels. 然后,您可以在选项卡视图面板中使用NSOutlineView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM