iOS 加载html图片修改图片大小
//html修改图片大小
//label.font.lineHeight: 图片宽度
let imgSize = "<head><style>img{width:\(label.font.lineHeight)!important;height:auto}</style></head>"
let myRichText = imgSize + content
let emotionStr = try! NSMutableAttributedString.init(data: (myRichText.data(using: String.Encoding.unicode))!, options: [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttributedString.DocumentType.html], documentAttributes: nil)
emotionStr.addAttribute(NSAttributedString.Key.font , value: label.font!, range: NSRange.init(location: 0, length: emotionStr.length))
label.attributedText = emotionStr
本文标题:iOS 加载html图片修改图片大小
本文链接:https://www.haomeiwen.com/subject/iwfrmctx.html
网友评论