co-*_*co- 5 html objective-c nsattributedstring ios
我有一些简单的 HTML,带有一个 blockquote 标签,我想在 a 中显示UILabel(它位于 内部UITableViewCell,所以我不认为 usingUIWebView是解决我的问题的方法)。
我决定将其转换为NSAttributedString并且一切正常,但我收到的是引用的文本,看起来与未引用的文本完全相同(没有缩进,没有块标记)。
我想问是否有什么方法可以实现类似于这里提到的现代引用的东西?或者至少在每行段落之前>使用一些缩进和前缀(例如老式电子邮件引用)NSAttributedString?
我知道你在 Obj-C 中问过这个问题,但我只是点击了一下,发现已经三年了,没有答案,而且我已经在其他地方这样做了,所以我不妨分享一下。
\n\nlet parsedCommentHTML = html.replacingOccurrences(of: "<blockquote>\\n", with: "<blockquote>\\n<k style=\\"color:#ccc; font-size: 2em; font-family: \'Copperplate\'\\">\xe2\x80\x9c</k>")\nlet blockQuoteCSS = "\\nblockquote > p {color:#808080; display: inline;} \\n blockquote { background: #f9f9f9;}"\nlet pCSS = "p {margin-bottom: 0px;}"\nlet cssStyle = "\\(blockQuoteCSS)\\n\\(pCSS)\\n"\n\nreturn try NSAttributedString(data: ("<html><head><style>\\(cssStyle)</style></head><span style=\\"font-family: HelveticaNeue-Thin; font-size: 17\\">\\(parsedCommentHTML)</span></html>").data(using: String.Encoding.unicode)!, options: [NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType], documentAttributes: nil)\nRun Code Online (Sandbox Code Playgroud)\n\n\n