ios html解析

2016-12-07  本文已影响0人  yanglifang

iOS解析HTMl标签以及开发中的一些坑 - 简书

1.Label的attributedString属性:

NSAttributedString *attrStr = [[NSAttributedString alloc] initWithData:[h5str dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nilerror:nil];

[selflab setAttributedText:attrStr];

2.利用web view

_webView = [[UIWebView alloc] initWithFrame:CGRectMake(100,100,100,100)];

NSString*html_str = [NSString stringWithFormat:@"666666测试 %@",@"新风作浪",@"2020-01-00"];

[self.webView loadHTMLString:html_str baseURL:nil];

[self.viewaddSubview:self.webView];

```[self.viewaddSubview:self.webView];

上一篇 下一篇

猜你喜欢

热点阅读