1
我有WKInterfaceLabel中,我可以不加載HTML標籤一樣如何在ios中的watchkit WKInterfaceLabel中加載html文本?
<h1>Grishneshwar Jyotirling</h1>
,我不能用NSMutableAttributedString
所以請幫我尋找有關的東西。
我有WKInterfaceLabel中,我可以不加載HTML標籤一樣如何在ios中的watchkit WKInterfaceLabel中加載html文本?
<h1>Grishneshwar Jyotirling</h1>
,我不能用NSMutableAttributedString
所以請幫我尋找有關的東西。
var htmlText = "<h1>Grishneshwar Jyotirling</h1> Grishneshwar Jyotirling"
let attributeText: NSAttributedString?
if let htmlData = htmlText.dataUsingEncoding(NSUnicodeStringEncoding) {
do {
attributeText = try NSAttributedString(data: htmlData , options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
myLabel.setAttributedText(attributeText)
}catch let e as NSError {
print("Couldn't translate \(htmlText): \(e.localizedDescription) ")
}