According to the application needs, the background will be sent over the HTML tag text displayed on the page, the first thought is to use wkwebview display, although it can be achieved but feel more memory consumption. Try loading HTML with lable, the code and the effect shown below, and find that the border style of the table is not loaded
NSString *str =@"Luomeng, Hello! Your borrowing item "0903. By month 3.02" the transfer of creditor's rights has been completed and the current holding information is as follows: <table border= ' 1 ' cellpadding= ' 0 ' width= ' 80%; ' cellspacing= ' 0 ' ><tr ><TD align= ' center ' > Username </td><td align= ' center ' > Debt holding amount </td></tr><tr><td align= ' center ' >13944831072</td><td align= ' center ' >2200.00</td></tr><tr><td align= ' center ' >13944831077</td><td align= ' center ' >600.00</td></tr><tr><td align= ' center ' >13944831078</td><td align= ' center ' >200.00</td></tr><tr><td align= ' center ' >13944831078</td><td align= ' center ' >200.00</td></tr><tr><td align= ' center ' >13944831078</td><td align= ' center ' >1800.00</td></tr><tr><td align= ' center ' >13944831078</td><td align= ' center ' >800.00</td></tr><tr><td align= ' center ' >13944831079</td><td align= ' center ' >400.00</TD></TR></TABLE> "; UILabel*lab = [[UILabel alloc] Initwithframe:cgrectmake ( the, -, k_screen_widhth- -, -)];lab.numberoflines=0; [Self.view Addsubview:lab]; Nsattributedstring* Attrstr =[[Nsattributedstring alloc] initwithdata:[str datausingencoding:nsunicodestringencoding] options:@{ Nsdocumenttypedocumentattribute:nshtmltextdocumenttype} documentattributes:nil Error:nil];lab.attributedText =Attrstr;lab.font= [Uifont systemfontofsize: the];
And then hold on to the mentality of TextView loading HTML tags to find the border style can be displayed, it should be the bottom of the lab and TextView do different processing, code and the effect is as follows
Uitextview *textview = [[Uitextview alloc]initwithframe:cgrectmake (K_SCREEN_WIDHTH-30, 300)]; textview.userinteractionenabled = NO; [Self.view Addsubview:textview]; nsattributedstring * Attrstr = [[Nsattributedstring alloc] initwithdata:[str datausingencoding: Nsunicodestringencoding] options:@{Nsdocumenttypedocumentattribute:nshtmltextdocumenttype} documentAttributes: Nil Error:nil];textview.attributedtext = Attrstr;textview.font = [Uifont systemfontofsize:15];
Summary TextView and lable can load HTML tag content, but TextView can load the style of the tag at the same time compared to lable, of course, through the webview can also be implemented to the HTML load but relatively more memory is not recommended here, Hope to be helpful to friends who meet the same problem
iOS loads HTML tags with lable and textview