如何将NSTextView设置为NSAttributedString?我不想使用textConainer,我试过了:
[myTextView insertText:myMutableAttributedString];但它并没有起作用。Nothing happened...not,甚至是警告或运行时错误。任何帮助都将不胜感激。
发布于 2012-09-13 08:25:34
文本视图必须可编辑才能插入。
[myTextView setEditable:YES];
[myTextView insertText:myMutableAttributedString];
[myTextView setEditable:NO];发布于 2016-10-18 01:00:56
在Swift 2.2中:
myTextView.textStorage?.setAttributedString(myMutableAttributedString)
在Objective-C中:
[[myTextView textStorage] setAttributedString:myMutableAttributedString];
发布于 2011-03-15 08:53:31
在调用该方法之前,应使用空字符串调用-setString (否则将文本插入到空字符串对象中):
[myTextView setString:@""];
[myTextView insertText:myMutableAttributedString];https://stackoverflow.com/questions/5293242
复制相似问题