问题
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:
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.
来源:https://stackoverflow.com/questions/14359339/how-can-i-set-the-font-and-line-spacing-on-html-i-load-into-a-webview