UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(50, 100, 260, 200)];
NSString *param = @"
This is
a para
graph with line breaks
";
NSAttributedString *attributedString = [[NSAttributedStringalloc] initWithData:[param dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}documentAttributes:nilerror:nil];
textView.attributedText = attributedString;
[self.view addSubview:textView];
网友评论