【发布时间】:2013-07-16 16:54:16
【问题描述】:
我正在尝试将属性字符串粘贴到我的 NSTextView 中,但它只是显示为纯文本,没有属性。我像这样创建了我的字符串:
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(滚动视图内)上,我仍然选中了“允许富文本”框,并且未选中“可编辑”框。我基本上是在尝试像控制台输出窗口一样使用它。
【问题讨论】:
标签: cocoa nstextview nsattributedstring