我尽最大努力搜索所有可能的解决方案以使其正常工作。我想知道是否可以将已经属性化的文本更改为具有其他属性的新属性化文本,而无需将其更改为字符串。
func updateSelectedText(attributes: [NSAttributedString.Key : Any]) {
let selectedRange = textView.selectedRange
let mutableAttributesString = NSMutableAttributedString(attributedString: textView.attributedText)
mutableAttributesString.setAttributes(attributes, range: selectedRange)
print(attributes)
print(selectedRange)
print(mutableAttributesString)
}