ユーザーがテキストファイルに入力するときに、新しい文字に以前の属性を継承させたいと思います。
現在、前の文字から属性を取得し、それを新しい範囲の新しい属性として追加していますか?代わりに以前のattributedStringを拡張するようにするにはどうすればよいですか?
// 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?