views:

36

answers:

1

Hi all I am using webview to display Data from RSS Feed Can I change color of WebView to Black From white. I have declare outlet in xib file named RemainingRssViewController and i am diplaying it from root view controller the code is

NSString *htmlstring =[[blogEntries objectAtIndex: blogEntryIndex] objectForKey: @"description"];
   NSURL *baseUrl;
baseUrl = [[NSURL alloc]initWithString:feedurl];

    [anotherViewController.maintext loadHTMLString:htmlstring baseURL:baseUrl];
  //maintext is the UIWebVeiw outlet in anotherViewController.
+1  A: 

Ok, looks good.

With this code:

NSString *htmlstring =[[blogEntries objectAtIndex: blogEntryIndex] objectForKey: @"description"];

You set up an HTML string to go in the UIWebView. However, it's not actually HTML, because right now it's just text. To solve this, we'll instead make the "htmlstring" to be styled HTML with the text from the XML feed.

For example:

NSString *textString = [[blogEntries objectAtIndex: blogEntryIndex] objectForKey:@"description"];

NSString *htmlstring = [NSString stringWithFormat:@"<html><head><style type='text/css'>body { color:#FFFFFF; background-color: #000000; }</style></head><body>%@</body></html>",textString];

Then, when the "htmlstring" is placed inside the UIWebView, it will be styled as you would like it to be.

Chromium
Thanks it work now please can you tell me how to change the text style to Arial and size to 10. i am sorry for such basic question but em very new to programming
Nauman.Khattak
Put this after `background-color: #000000;` : `font-family: Arial; font-size: 10pt;`
Douwe Maan
Thanks I have done it.... @Douwe best of luck in worldcup final.....You guys are very helpfull.
Nauman.Khattak
@Naumankhattak Haha, thanks :D
Douwe Maan