2

我試圖添加一些格式到基於視圖的NSOutlineView中的單元格。無論我嘗試什麼,文本都會以我指定的任何格式呈現。這是我目前的做法:NSAttributedString在基於視圖的NSOutlineView呈現爲普通字符串?

NSMutableAttributedString *versionString = [[NSMutableAttributedString alloc] 
              initWithString:myString]; 
[versionString addAttribute:NSForegroundColorAttributeName 
         value:[NSColor redColor] range:NSMakeRange(0, 3)]; 

NSTableCellView result = [outlineView makeViewWithIdentifier:@"DataCell" 
                 owner:self]; 
result.textField.allowsEditingTextAttributes = YES; 
result.textField.attributedStringValue = versionString; 

是不可能在NSOutlineView和標準NSTextField中呈現屬性字符串?

回答

4

好的,問題是大綱視圖高亮顯示樣式是Source。將其設置爲Regular或None將允許屬性字符串。