简体   繁体   English

如何使NSTextView使用特定的NSTextStorage?

[英]How can I make a NSTextView use a specific NSTextStorage?

Is there a way set an NSTextView's textStorage property to my own NSTextStorage? 有没有办法将NSTextView的textStorage属性设置为我自己的NSTextStorage? You can customize the NSTextContainer, so is there a way to do something like this: 您可以自定义NSTextContainer,因此可以执行以下操作:

NSTextView *myTV = [[NSTextView alloc] initWithFrame:CGFrameMake(0,0,100,100) 
                                    withTextStorage:myTextStorage];

If not, is there a way to swap out the default text storage after the text view is instantiated? 如果没有,是否有办法在实例化文本视图之后换出默认文本存储空间? Does this need to be done by subclassing NSTextView? 是否需要通过子类化NSTextView来完成?

在文本存储中设置属性字符串。

[[myTV textStorage] setAttributedString:myTextStorage];

除了简单地替换存储中的字符串外,似乎还没有办法替换NSTextStorage对象本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM