How to display html formatted text in ios label

前端 未结 7 1385
逝去的感伤
逝去的感伤 2020-12-24 00:55

I would like to display html formatted text on a UILabel in IOS.

In Android, it has api like this .setText(Html.fromHtml(somestri

7条回答
  •  滥情空心
    2020-12-24 01:42

    Objective-C Version:

       NSError *error = nil;
       NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:contentData
                                                        options:@{NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType}
                                                        documentAttributes:nil error:&error];
    

    This is just the Objective-C conversion of the above answers. All the answers above are right and reference taken from the above answers for this.

提交回复
热议问题