ios - 从服务器接的数据包含有html格式,使用NSAttributedString显示,但是如何能够修改字体大小。
PHP中文网
PHP中文网 2017-04-17 17:58:31
0
2
329

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

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

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
大家讲道理

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

阿神

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template