开发者

Unable to change colour in UIWebView

开发者 https://www.devze.com 2023-03-14 19:27 出处:网络
I\'m using th开发者_C百科e following code it is working fine if I want to make a HTML page but it is not working on UIWebView. it looks like don\'t know why web view is not rendering the HTML tags. Is

I'm using th开发者_C百科e following code it is working fine if I want to make a HTML page but it is not working on UIWebView. 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:

Unable to change colour in UIWebView

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号