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

我将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;

}

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

这是一张图片:

这里发生了什么?

最佳答案 层背衬又是一种奇怪之处.所以我把它关了:(

点赞