I try to load HTML with images to the UITextView, but images don't want to fit the width of screen, they are toooo large. Attribute width for IMG tag and CSS don't help :(
Here's the code:
var content = "<html><head><meta charset='utf-8'><title>«Первый поворот налево или направо?» Секреты успеха Льюиса Хэмилтона</title><style>img {max-width: '100%'; width: '100%'; height: auto;}body{ color:red }</style></head><body><p>Иногда его превосходство заметно сразу – как в случае с потрясающей скоростью вхождения в первый поворот на Гран При Австралии нынешнего года, а иногда не столь очевидно.</p><p><img src='http://autosport.com.ru/files/feature/2018/06/29/ba7222d642a69863db32ec8e5d2e8b8f.jpg' alt='Льюис Хэмилтон © autosport.com'/>Льюис Хэмилтон</p>"
let htmlData = NSString(string: content).data(using: String.Encoding.unicode.rawValue)
let options = [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html]
let attributedString = try! NSAttributedString(data: htmlData!, options: options, documentAttributes: nil)
txtView.attributedText = attributedString