Monday, April 5, 2010

Transparent Background on iPhone UIWebView

Simple solution to creating a UIWebView with a transparent background:

  • set your background color of the UIWebView to clear
  • set the css for the body to background-color: transparent
  • here's the bugger... set the opaque property of the UIWebView to NO
Code
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 310,450)]; self.bounds.size.height-60)];
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
[self.view addSubview:webView];
cheers

No comments:

Post a Comment