美文网首页收藏问题
TextView加载带有html标签的字符串

TextView加载带有html标签的字符串

作者: 小小纳兰 | 来源:发表于2017-09-19 15:09 被阅读8次
    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];
    

    相关文章

      网友评论

        本文标题:TextView加载带有html标签的字符串

        本文链接:https://www.haomeiwen.com/subject/wigwsxtx.html