我尝试在文本开头的UITextView中添加项目符号,但是当我使用此代码添加时,旧的attributionString和字体和大小都没有保存。
在此代码中:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:currentTextViewEdit.text];
NSMutableParagraphStyle *paragrahStyle = [[NSMutableParagraphStyle alloc] init];
[paragrahStyle setParagraphSpacing:4];
[paragrahStyle setParagraphSpacingBefore:3];
[paragrahStyle setFirstLineHeadIndent:0.0f]; // First line is the one with bullet point
[paragrahStyle setHeadIndent:10.5f]; // Set the indent for given bullet character and size font
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragrahStyle range:NSMakeRange(0, [currentTextViewEdit.text length])];
currentTextViewEdit.attributedText = attributedString;
currentTextViewEdit.text = [NSString stringWithFormat:@"1.%@",currentTextViewEdit.text];
我尝试添加一个NSMutableParagraphStyle但它删除了之前文本所具有的旧NSMutableAttributedString。