The recent use of Swift as a small company project has encountered the problem that the tags in the HTML text obtained through the API have been escaped,
<P class="MsoNormal"align="Left"style="Vertical-align:baseline;background:white;">\n\t<BR/>\ n</P>\ n<P class="MsoNormal"align="Left"style="Vertical-align:baseline;background:white;">\n\t<B>(Original title: New owner must see!) It is necessary to keep the car repaired by car.</b><B>20</b><B>Big</b><B>“</b><B>Iron Law</b><B>”)</b>\ n</P>\ n<P class="MsoNormal"align="Left"style="Vertical-align:baseline;background:white;">\N\T2016-06-13 19:09\n</P>\ n<P class="MsoNormal"align="Left"style="Vertical-align:baseline;background:white;">\n\t<B>1.</b><B>The new car and the two are the most important</b>\ n</P>\ n<P class="MsoNormal"align="Left"style="Vertical ..... ..... ...........................
Call WebView directly. loadHTMLString(content!, BaseURL: nil) will look like in the figure below in WebView
Finally, a string extension was found on the Magnum GitHub
Import Foundationimport uikitextension String { var htmltostring:string { Returntry! Nsattributedstring (data:datausingencoding (nsutf8stringencoding)!, options: [Nsdocumenttypedocumentattribute: Nshtmltextdocumenttype,nscharacterencodingdocumentattribute:nsutf8stringencoding], Documentattributes:nil). string }}
Perfect solution
Mark here.
How to restore HTML tags after iOS is in transit