0

我想从 html 代码中显示一个视图,这是我从 web 视图添加到主视图的代码,

- (void) createWebViewWithHTML{
//create the string
NSMutableString *html = [NSMutableString stringWithString: @"<html><head><title></title></head><body style=\"background:transparent;\">"];

//continue building the string
[html appendString:@"body content here"];
[html appendString:@"</body></html>"];

//instantiate the web view
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];

//make the background transparent
[webView setBackgroundColor:[UIColor clearColor]];

//pass the string to the webview
[webView loadHTMLString:[html description] baseURL:nil];

//add it to the subview
[self.view addSubview:webView];

但问题是:1,uiwebview的背景是白色不透明2,我想在我的代码中添加css和自定义字体,请给我一个例子或解决方案或示例代码谢谢你的帮助!

4

1 回答 1

0

这对我有用: http ://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-uiwebview-with-a-transparent-background-in-iphone/

希望能帮助到你!

于 2012-07-23T11:29:11.557 回答