【发布时间】:2017-09-28 02:28:14
【问题描述】:
首先想说谢谢你,如果这可以解决..所以我有 textview 用 html 标签获取数据..所以我使用属性文本和函数来呈现 html..它工作..但我需要改变字体系列..现在默认情况下它是“times new roman”我想改成“Helvetica”有什么线索吗?我为此使用扩展名:
extension Data {
var attributedString: NSAttributedString? {
do {
return try NSAttributedString(data: self, options:[NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue], documentAttributes: nil)
} catch {
print(error)
}
return nil
}}
extension String {
var data: Data {
return Data(utf8)
}}
然后我用它:
cell.txtview.attributedText = contentText.data.attributedString
它有效,但字体默认变为“times new roman”我需要更改它..任何想法?之前非常感谢..谢谢!
我也已经尝试过了……见下图
【问题讨论】:
标签: ios iphone swift mobile swift3