I want to load an rtf into a web view with a clear background. The general consensus on creating a UIView with a clear background requires adding html code to set the background-color:transparent like this...
myWebView.backgroundColor = [UIColor clearColor];
mytWebView.opaque = NO;
[yWebView loadHTMLString:@"<html><head><styl开发者_高级运维e>body{background-color:transparent;}</style> </head><body>your content here!</body></html>" baseURL:nil];
How do I format the HTML string to include the rtf.
Thanks,
John
You can load the html inside of an NSString using the stringWithFormat method. Assuming a string called
rtf` that holds the contents of your RTF, simply use the following line:
[yWebView loadHTMLString:[NSString stringWithFormat:@"<html><head><style>body{background-color:transparent;}</style> </head><body> %@ </body></html>", rtf] baseURL:nil];
Note the %@
where your RTF goes and the nested stringWithFormat:
call.
精彩评论