1 使用uiview显示hml
Demo+NSAttributedString-Additions-for-HTML.zip
Demo+NSAttributedString-Additions-for-HTML.zip
NSAttributedString-Additions-for-HTML-master.zip
2使用TTTAttributedLabel不支持对齐,显示hml
使用由 NSAttributedString-Additions-for-HTML的[NSAttributedStringalloc]initWithHTML
来生成TTTAttributedLabel所需要的NSAttributedStrings就可以用UIable显示html了
3使用OHAttributedLabel支持对齐 (推荐)
- //html内容
- NSString *name = [dataArray objectAtIndex:row];
- //必须设置
- cell.name.text = name;
- //居中显示
- cell.name.textAlignment = NSTextAlignmentCenter;
- //转换
- NSMutableAttributedString *string = [OHASBasicHTMLParser attributedStringByProcessingMarkupInAttributedString:cell.name.attributedText];
- //再设置
- cell.name.attributedText = string;
本文介绍了在iOS开发中使用不同方法展示HTML内容的技巧:利用UIView显示HTML;使用TTTAttributedLabel显示HTML但不支持对齐;推荐使用OHAttributedLabel显示HTML,支持对齐并提供更好的显示效果。
9792

被折叠的 条评论
为什么被折叠?



