【发布时间】:2016-12-07 20:11:53
【问题描述】:
我在一个 iOS 项目中工作,我有这个 HTML 文本需要在 UITextView 中显示:
<a href="http://google.com" target="_blank" rel="nofollow" title="Link: http://google.com">http://google.com/</a><br><span class="wysiwyg-color-d24b57 ">TEST<br><i><span class="wysiwyg-color-704938 ">TEST2<br></span></i></span><div class="wysiwyg-text-align-left "><span class="wysiwyg-color-d24b57 "><span class="wysiwyg-color-704938 "><u><span class="wysiwyg-color-3a529c ">Test3<br>TEST4<br><br></span></u><span class="wysiwyg-color-3a529c wysiwyg-font-size-x-large ">Test5</span><u><span class="wysiwyg-color-3a529c "><br><br><br></span></u></span></span></div>
到目前为止,我已经创建了 NSAttributedString 和 UITextView:
NSAttributedString *attributedString = [[NSAttributedString alloc]
initWithData: [example.text dataUsingEncoding:NSUnicodeStringEncoding]
options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
documentAttributes: nil
error: nil
];
UITextView *textView = [[UITextView alloc] init];
textView.frame = [node labelFrame];
textView.attributedText = attributedString;
textView.editable = NO;
textView.selectable = YES;
textView.backgroundColor = [UIColor clearColor];
return textView;
现在我必须对其应用所见即所得的 CSS,因为目前,颜色、字体大小和对齐方式都不起作用。
有人知道怎么做吗?
提前致谢!
【问题讨论】:
标签: html ios css objective-c