// // ContentViewController.swift // xingchuangke // // Created by Apple on 2020/10/31. // Copyright © 2020 Virgil. All rights reserved. // import UIKit class ContentViewController: BaseViewController { var titleStr = "" var strHtml = "" override func viewDidLoad() { super.viewDidLoad() self.title = titleStr initNavLeftBackButton() let label:UITextView = UITextView() label.text = strHtml label.isEditable = false label.frame = CGRect(x:self.view.frame.origin.x+20, y:self.view.frame.origin.y+20, width:self.view.frame.size.width-40, height:self.view.frame.size.height-40); self.view.addSubview(label) let width:CGFloat = ( SCREEN_WIDTH-60); let str:NSString = "%@" as NSString; strHtml = NSString(format: str,strHtml,width,width) as String let data:Data = strHtml.data(using: String.Encoding(rawValue: String.Encoding.unicode.rawValue))! do { let attrinbuteString: NSAttributedString = try! NSAttributedString.init(data: data, options: [ NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html ], documentAttributes: nil) DispatchQueue.main.async { label.attributedText = attrinbuteString } } // Do any additional setup after loading the view. } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "ContentViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }