// // String+HtmlAttributed.swift // elpha-ios // // Created by Dwayne Harris on 11/6/18. // Copyright © 2018 Elpha. All rights reserved. // import UIKit extension String { func htmlAttributed(size: CGFloat, centered: Bool = false, color: UIColor? = nil) -> NSAttributedString? { let color = color ?? UIColor(named: "Text")! do { let htmlString = """ \(self) """ guard let data = htmlString.data(using: String.Encoding.utf16) else { return nil } return try NSAttributedString( data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil ) } catch { print("\(error)") return nil } } }