8
我試圖將一個屬性字符串粘貼到我的NSTextView,但它只是顯示爲純文本,沒有屬性。我創造了我的字符串,像這樣:NSTextView和NSAttributedString
NSString *str = @"Parsing Directory Structure\n\n";
NSMutableAttributedString *attrstr = [[NSMutableAttributedString alloc] initWithString:str];
NSDictionary *attributes = @{
NSForegroundColorAttributeName : [NSColor blueColor],
NSFontAttributeName : [NSFont fontWithName:@"HelveticaNeue-Bold" size:20.f]
};
[attrstr setAttributes:attributes range:NSRangeFromString(str)];
[[self.textView textStorage] appendAttributedString:attrstr];
,並在NSTextView(滾動視圖中)我已經得到了「允許富文本」框中選中靜止了,可編輯勾選。我基本上試圖使用這個像控制檯輸出窗口。
謝謝!這工作完美。 – Gargoyle