如何在Swift中将blockquote应用于UIWebView

如何在Swift中将blockquote应用于UIWebView,swift,uiwebview,Swift,Uiwebview,我正在使用为用户提供一个富文本编辑器 结果字符串为: "<b>Bold is working&nbsp;</b><i>Italic as well</i>\n<blockquote>But sadly... blockquote is not\n<ul>\n\t<li>Lists are working</li>\n</ul>\n</blockquote>" 几乎每

我正在使用为用户提供一个富文本编辑器

结果字符串为:

"<b>Bold is working&nbsp;</b><i>Italic as well</i>\n<blockquote>But sadly... blockquote is not\n<ul>\n\t<li>Lists are working</li>\n</ul>\n</blockquote>"
几乎每件事都是我想要的,但这句话是错误的

如何将蓝色/灰色背景应用于第一个屏幕中的blockquote

非常感谢您的帮助。

我的解决方法:

func getFormattedHTMLString(_ entryString: String) -> String {
    let cssStyle = "<style>div {border: 0px solid black;background-color: #E1E8F2;padding-top: 10px;padding-right: 0px;padding-bottom: 10px;padding-left: 10px;}</style>"
    let removedBlockquoteEntries = entryString.replacingOccurrences(of: "<blockquote>", with: "<div>")
    let removedBlockquoteEndings = removedBlockquoteEntries.replacingOccurrences(of: "</blockquote>", with: "</div>")

    let result = "<html><head>\(cssStyle)</head><body><font face='SourceSansPro' color='black' size='5'>\(removedBlockquoteEndings)</font></body></html>"
    return result
}
func getFormattedHTMLString(\uEntryString:String)->String{
让cssStyle=“div{border:0px纯黑色;背景色:#E1E8F2;顶部填充:10px;右侧填充:0px;底部填充:10px;左侧填充:10px;}”
让removedBlockquoteEntries=entryString.replacingOccurrences(of:,with:)
let removedBlockquoteEndings=removedBlockquoteEntries.replacingOccurrences(of:,with:)
let result=“\(cssStyle)\(removedBlockquoteEndings)”
返回结果
}
我在字符串中添加了CSS代码和HTML标记

然后,我将
标记替换为
标记

用法:
webView.loadHTMLString(getFormattedHTMLString(txt),baseURL:nil)

结果:


好吧,您的字符串没有对blockquote应用任何样式,这就是为什么您看不到任何颜色。我确信编辑器引用的是CSS文件。
func getFormattedHTMLString(_ entryString: String) -> String {
    let cssStyle = "<style>div {border: 0px solid black;background-color: #E1E8F2;padding-top: 10px;padding-right: 0px;padding-bottom: 10px;padding-left: 10px;}</style>"
    let removedBlockquoteEntries = entryString.replacingOccurrences(of: "<blockquote>", with: "<div>")
    let removedBlockquoteEndings = removedBlockquoteEntries.replacingOccurrences(of: "</blockquote>", with: "</div>")

    let result = "<html><head>\(cssStyle)</head><body><font face='SourceSansPro' color='black' size='5'>\(removedBlockquoteEndings)</font></body></html>"
    return result
}