【发布时间】:2011-07-21 22:49:04
【问题描述】:
当用户输入我的文本文件时,我希望新字符继承之前的属性。
我目前从前一个字符中获取属性并将其添加为新范围的新属性?我怎样才能让它扩展之前的属性字符串呢?
// 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?
【问题讨论】:
标签: iphone objective-c nsattributedstring