在我的应用程序,我将在更改归属字符串的单个字体属性。
<p style = "text-align: center;"><strong>"some text in here</strong></p>
我知道如何使用下面的函数这个网站字符串转换为构造一个AttributedString格式得到一个HTML字符串。
[[NSAttributedString alloc] initWithData:[aboutData dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil];
但问题是,我希望保留获得AttributedString的所有属性,但可以改变任何字体大小,字体,这达到attributedString的段落样式。
例如,如果我从这个html中获得一个大胆的attributesString,我怎么能改变这个特定字符串的字体大小或字体系列而不改变它的大胆状态?
我该怎么做?
谢谢!
http://stackoverflow.com/questions/19921972/parsing-html-into-nsattributedtext-how-to-set-font http://stackoverflow.com/questions/25401742/apply-custom-font-to-归属字符串,它转换从HTML字符串http://stackoverflow.com/questions/41412963/swift-change-font-on-an-html-string-that-has-its-own-styles/41413014 #41413014 – Larme