问题描述
我以为我在某处读到有一种方法可以在文本视图中嵌入图形或其他非文本,但我在苹果文档中找不到任何东西。任何人都可以指向正确的方向?我试图构建一个编辑器,而不只是一个视图。我想象在底层文本中的特殊字符,并基于文本属性,它将在文本布局中保留一些空白。 ?或者也许我需要自己布局块,使用NSTextContainers和自定义NSView流动图形周围的文本?
I thought I read somewhere that there is a way to embed drawings or other non-text in a text view, but I can't find anything about it in the Apple documentation. Can anyone point me in the right direction? I'm trying to build an editor, not just a view. I'm imagining a special character in the underlying text, and based on text attributes, it would reserves some blank space in the text layout. ? Or maybe I need to layout blocks myself, using NSTextContainers and a custom NSView to flow text around graphics?
推荐答案
查看NSTextAttachment和NSTextAttachmentCell。您可以在子类化NSTextAttachmentCell时自己绘制自定义图形。
Take a look into the NSTextAttachment and NSTextAttachmentCell. You can do your own custom drawing when you subclass the NSTextAttachmentCell.
Apple文档:
这篇关于在NSTextView混合图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!