Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Development - Setting UIWebView font

I have to show rich text that i pull from server, so i'm using UIWebView. Now the problem is that i have no control over the font which is used in UIWebView. How can i change the font to use system font (making it consistent with rest of the application)?

I'm doing something like this at the moment:

myRichTextView = [[UIWebView alloc] initWithFrame:CGRectMake(x, y, width, height)]; myRichTextView.backgroundColor = [UIColor clearColor]; [myRichTextView setScalesPageToFit:NO]; [myRichTextView loadHTMLString:myString baseURL:[NSURL URLWithString:myBaseURL]]; 

Again, need to control the display font. If i can't control the font, please let me know other alternatives to UIWebView.

Thanks

like image 915
Mustafa Avatar asked Jan 16 '09 07:01

Mustafa


1 Answers

It worked when i modified the string like this. Your right chris, it shouldn't make any difference.

NSString *myDescriptionHTML = [NSString stringWithFormat:@"<html> \n"                                 "<head> \n"                                 "<style type=\"text/css\"> \n"                                 "body {font-family: \"%@\"; font-size: %@;}\n"                                 "</style> \n"                                 "</head> \n"                                 "<body>%@</body> \n"                                 "</html>", @"helvetica", [NSNumber numberWithInt:kFieldFontSize], content]; 
like image 158
Mustafa Avatar answered Sep 20 '22 16:09

Mustafa