IOS 当使用富文本加载HTML内容的时候,HTML中英文的font-family变成了Times New Roman,如何使用默认字体。

在IOS开发过程中,需要在UITextView中加载HTML的代码片段,加载代码如下

NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithData:[[self.dataDic objectForKey:@"translate"] dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];

但是在页面中,加载的英文的font-family变成了Times New Roman

图片说明

我尝试过设置富文本的font属性,但是这样的话 我的HTML中的文本显示的就不正确了(加粗会不显示,其他的没有尝试)。
图片说明

如果我设置了Font属性,文本的加粗效果就不能显示。我在Log中看到加粗的文本的font-family是Times new Roman-bold,但是我不清楚再何时设置加粗的字体,此外其他的效果会不会影响。

图片说明

上面是UITextView的代码段

本人IOS小白,刚开始做,想问问这种情况有没有什么解决办法?

https://blog.csdn.net/qls321/article/details/62222966

https://developer.apple.com/forums/thread/90244  中给了回答。

let string = self.appending(String(format: "<style>body{font-family: '%@'; font-size:%fpx;}</style>", fontName, fontSize))