开发者

how do you load an rtf into a UIWebView with a clear background

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 calledrtf` 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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜