Home  >  Q&A  >  body text

ios - 从服务器接的数据包含有html格式,使用NSAttributedString显示,但是如何能够修改字体大小。

从服务器接的数据包含有html格式,使用
NSDictionary *dict = @{NSFontAttributeName:[UIFont systemFontOfSize:24.0f]};

[[NSAttributedString alloc] initWithData:@xxxxx"" dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:&dict error:nil];,
不起作用,字体还是很小,如何解决。

PHP中文网PHP中文网2741 days ago320

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 18:00:31

    You can use NSString *htmlString = [NSString stringWithFormat:@"<head><style>body{font-family:arial,Helvetica;font-size:15;word-wrap:break-word;}</style></head>"]; to splice it into the returned string

    reply
    0
  • 阿神

    阿神2017-04-17 18:00:31

    Your initialization method is not systematic. Go and see if this method of logic is wrong

    reply
    0
  • Cancelreply