比如我有@“很久很久以前。”,@“有一个孩子。”,@“bla bla bla”等3个句子,我在下面做了一个方法
- (void)appendText:(NSString*)text
{
NSMutableAttributedString *originalText = [[NSMutableAttributedString alloc] initWithAttributedString:_textView.attributedText];
NSAttributedString *appendText = [[NSAttributedString alloc] initWithString:text
attributes:@{NSForegroundColorAttributeName:DefaultTextColor}];
[originalText appendAttributedString:appendText];
_textView.attributedText = originalText;
}
所以我调用了 appendText 3 次
[self appendText:@"Long long ago."];
[self appendText:@"There is a child."];
[self appendText:@"bla bla bla."];
我期望的结果是
Long long ago.There is a child.bla bla bla.
但输出是
Long long ago.
There is a child.
bla bla bla
为什么 appendAttributedString 在新行中显示附加字符串?如何将附加文本放在一个段落中?
谢谢你的帮助。