Hadi Hadi - 3 months ago 7x
HTML Question

Unable to change colour in UIWebView

I'm using the following code it is working fine if I want to make a HTML page but it is not working on

. it looks like don't know why web view is not rendering the HTML tags. Is there any way I can fix it?

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

[webView loadHTMLString:htmlString baseURL:nil];


This code works for me:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *string = [[NSString alloc] initWithFormat:@"Helooooooo"];
    NSString *htmlString = [[NSString alloc] initWithFormat:@"<html><head><style type='text/css'>body { color:#FFFFFF; background-color: #000000; }</style></head><body>%@</body></html>", string];
    [webView loadHTMLString:htmlString baseURL:nil];

Here's a screenshot:

enter image description here