How can I set the font and line spacing on HTML I

2019-07-27 06:53发布

I have an iOS app that parses articles from a remote rss feed.

When I format it through a webview and "LoadHTMLString:withURL," the text is formatted with some default font/line spacing. I want to set my own font/line spacing, and I think that this can be done if I include the correct HTML formatting code as a string in the beginning of each article.

This way I'll manipulate XCode to format the string for my liking.

The only thing is that when I add the line

<p style="font: 20pt/30pt Times New Roman, serif;">

The text still remains unformatted. I feel like this might be because it creates a nil paragraph which is formatted, but is also nil, so there is no detectable change.

1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-27 07:19

The code set a paragraph in a paragraph so it didn't work, but if you set it up as

     NSMutableString *htmlString = [NSMutableString stringWithFormat:@"<div style=\"font: 20pt/30pt Times New Roman, serif;\">%@</div>", textFile ];

instead, it works fine.

查看更多
登录 后发表回答