NSAttributedString删除线不会绘制整个文本长度

时间:2011-02-17 02:06:29

标签: nstableview

我将NSAttributedString插入到NSTableView中,根据它的内容,我在其样式字典中添加属性。

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {


NSAttributedString *theValue;
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
[attributes setObject:[NSFont systemFontOfSize:11] forKey:NSFontAttributeName];
currentObject = [ticketsDataSource objectAtIndex:rowIndex];

if ([[currentObject valueForKey:aTableColumn.identifier] isKindOfClass:([NSString class])]) {

    NSString *currentValue = [currentObject valueForKey:aTableColumn.identifier];

    if ([currentValue isEqualToString:@"resolved"]) {

        [attributes setObject:[NSColor colorWithCalibratedRed:0.344 green:0.619 blue:0.000 alpha:1.000] forKey:NSForegroundColorAttributeName];

    }

    if ([previousValue isEqualToString:@"resolved"]) {

        [attributes setObject:[NSNumber numberWithInteger:NSUnderlinePatternSolid | NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
    }

    theValue = [[NSAttributedString alloc] initWithString:currentValue attributes:attributes];
    previousValue = currentValue;

}

正如您所看到的,基本上发生的事情是当它写一个名为“已解决”的字符串时,它知道下一列,即标题列,会得到一个删除线。它工作正常,但无论出于何种原因,删除线并没有覆盖整个文本!

这是一张图片:

enter image description here

这里发生了什么?

1 个答案:

答案 0 :(得分:2)

又有层次支持的怪异。所以我把它关了:(