当预定义每行文本时,证明UITextView文本是正确的

时间:2014-08-05 12:27:44

标签: objective-c io uitextview

我有一个UITextView多行。每行的每个文本都将从数据库中获取,并将显示在UITextView上。由于每行的文本是预定义的,因此特定行的文本不应显示在另一行上。这对我来说可以。但是TextView没有道理。如何在不更改每行文本的情况下证明TextView的文本。你能帮我吗?

2 个答案:

答案 0 :(得分:0)

NSMutableAttributedString *title = [[NSMutableAttributedString alloc]initWithString:@"your custom string with '\n' between each line"];

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setAlignment:NSTextAlignmentJustified];
[title addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, title.length)];

titleView.attributedText = title;

答案 1 :(得分:0)

您可以设置属性" textAlignment"像这样的UITextView: textView.textAlignment = NSTextAlignmentJustified;