我有一个NSTextAttachment子类,它被覆盖了attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:imageForBounds:textContainer:characterIndex:。我需要在某个时候重新绘制附件。在UITextView上调用setNeedsDisplay无效。有什么想法吗?我想避免重新创建附件和/或属性字符串。 最佳答案 您需要使用textView.layoutManager的方法之一。i