Search code examples
objective-cfontsuiwebviewxcode8ios10

Load default system font for UIWebview


I've two views on my view one is a UIWebview and other is a UITextView and I want both of them to display system default font. But, I just loaded a plain HTML text on my UIWebview and loaded another plain text on textview with default system font. On UIWebview it looks like Times New Roman and on textview it looks like Helvetica. Does the default system font differs for UIWebview?

This is the HTML page source that I load and below is a textview that uses system font.

<html>
<body>

This is a sample html Page


</body>
</html>

enter image description here


Solution

  • UIWebView is just a Safari component inside your app. So when you put HTML content into it, you're kind of loading a page.

    The default fontface for web content is Times New Roman, so if you want to change it you need to style your HTML content to change default fontface, using the same type as the system.