有分裂的 NSCell
我想知道是否有一种方法可以像下面的示例一样绘制 NSCell。这个想法是在同一列中容纳 3 行,第一行有足够的空间放置标题,其余的有 2 列。
TITLE________________< em>__________< /em>_________________< em>___________
DATA_TITLE_1:DATA_VALUE_1 _ _ _ DATA_TITLE_2:DATA_VALUE_2
DATA_TITLE_3: DATA_VALUE_1 _ _ _ DATA_TITLE_4: DATA_VALUE_2
注意:
- “_ _ _”应该是三个空格(我不知道如何表示它们)。
- 请记住,列标题和值长度会有所不同。
提前致谢。
I want to know if there is a way of drawing an NSCell like the following sample. The idea is to fit in the same column, 3 rows, the first one with enough space for a Title, and the rest with 2 columns.
TITLE______________________________________________________
DATA_TITLE_1: DATA_VALUE_1 _ _ _ DATA_TITLE_2: DATA_VALUE_2
DATA_TITLE_3: DATA_VALUE_1 _ _ _ DATA_TITLE_4: DATA_VALUE_2
Notes:
- The "_ _ _" were suposed to be three spaces (I don't know how to represent them).
- Bare in mind that the column titles and values length will vary.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有标准的 NSCell 可以执行此操作,但您可以编写自己的 NSCell 类之一的子类并使其执行此操作。请参阅控制和单元编程主题。
There's no standard NSCell that can do this, but you can write your own subclass of one of the NSCell classes and make it do this. See the Control and Cell Programming Topics.
事实证明,当子类化 NSCell 时,您可以根据需要在框架内添加任意数量的单元格。您只需重写drawInteriorWithFrame方法分配一个NSCell,然后将其绘制在单元格框架内的任何位置。
这是一个简单的例子:
As it turns out, when subclassing NSCell you may add as many cells within the frame as you want. You've just have to override the drawInteriorWithFrame method alloc an NSCell and then draw it anywhere within the frame of the cell.
Here it's a simple example: