当用户输入我的文本文件时,我希望新字符继承以前的属性。
我目前从前一个字符获取属性并将其添加为新范围的新属性?我怎样才能使它扩展以前的属性字符串呢?
// What I have
"a"{attribute1 (0,1)} "b"{attribute2 (1,1)} "c"{attribute3(2,1)}
// What I'm trying to do
"abc" {attribute1 (0,3)}
注意:这必须发生在用户键入的每个字符上,因此当用户键入时,新字符应该继承之前的属性。
编辑:更多信息
// So I create a new AttributedString, added it to my mutable string
NSAttributedString *newString = [[NSAttributedString alloc] initWithString:USER_INPUT attributes:self.defaultAttributes];
[_mutableAttributedString insertAttributedString:newString atIndex:selectedNSRange.location];
// Is it possible to add the USER_INPUT to the end of my mutable attributedString and extends the range of the previous attribute?