2017-04-12 1 views
0

私はfollowing Wordpress Editor Frameworkを使用して、リッチテキストエディタを提供しています。スウィフトのUIWebViewにblockquoteを適用する方法

enter image description here

得られた文字列である:

"<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>" 

私の考え、同じ形式で、最終的な文字列を表示するUIWebViewを使用することでした。

let result = "<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>" 
contentWebView.loadHTMLString("<html><body><font face='SourceSansPro' color='black'>\(result)</font></body></html>", baseURL: nil) 

私はそれがほしいと思う方法ですが、ブロッククォートです。

最初の画面のように、青色/灰色の背景をブロッククォートに適用するにはどうすればよいですか?

enter image description here

ヘルプは非常に感謝されます。

+0

さて、あなたの文字列がBLOCKQUOTEに任意のスタイルを適用していない、というのです。私はエディタがCSSファイルを参照していると確信しています。 –

答えて

0

私の回避策:

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 
} 

私は、文字列だけでなく、HTMLタグにCSSのコードを追加しています。

次に、<blockquote>タグを<div>タグに置き換えました。

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

Resul:あなたは任意の色を見ていない理由を

enter image description here

関連する問題