【发布时间】:2017-11-07 08:21:37
【问题描述】:
我想以斜体显示文本,从服务器接收到的粗体。
你好世界
所以,responseObj!["text"] = "<p><b><i>hello</i></b><i>world</></p>"
if let postText:String = responseObj!["text"] as? String{
let str = try NSAttributedString(data: postText.data(using: String.Encoding.unicode, allowLossyConversion: true)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
self.textView.attributedText = str
}
当我像这样添加时,意味着我的文本显示正常而不应用粗体和斜体。我希望文本以粗体、斜体显示。
【问题讨论】: