欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

iOS---TextView显示HTML文本

程序员文章站 2022-06-02 22:27:05
_checkallintroducetextview = [[uitextview alloc] initwithframe:cgrectmake(10, 0, kscreenwidth-20, k...

_checkallintroducetextview = [[uitextview alloc] initwithframe:cgrectmake(10, 0, kscreenwidth-20, kscreenheight)];

_checkallintroducetextview.backgroundcolor = self.view.backgroundcolor;

_checkallintroducetextview.returnkeytype=uireturnkeydone;

_checkallintroducetextview.delegate = self;

_checkallintroducetextview.showsverticalscrollindicator = no;

nsattributedstring *attributedstring = [[nsattributedstring alloc] initwithdata:[@"后台返回给你的html格式的字符串" datausingencoding:nsunicodestringencoding] options:@{ nsdocumenttypedocumentattribute: nshtmltextdocumenttype } documentattributes:nil error:nil];

_checkallintroducetextview.attributedtext = attributedstring;

_checkallintroducetextview.textcolor = kcolor_gray_6;

[self.view addsubview:_checkallintroducetextview];