2011-09-23 25 views

回答

11
webView.alpha=0.5f; 

[webView setBackgroundColor:[UIColor clearColor]]; 

[webView setOpaque:NO]; 
+0

我认为这只能让你在一半。您仍然必须使网页的主体半透明。 – MusiGenesis

+0

非常感谢。 – Wooly

+0

欢迎好友......... –

2

看起来这可能,也许。看到这个博客帖子:

http://erikloehfelm.blogspot.com/2009/04/transparent-background-on-iphone.html

使背景半透明取决于你是否能在网页的body元素的CSS颜色设置为半透明色(而不是“透明”) 。

另外,如果您不控制要显示的网页的HTML,则此博客文章不会显示如何执行此操作,但可以通过UIWebView以编程方式更改此页面的颜色内容已加载。

0

玩弄改变透明任何颜色/ alphawebView.backgroundColor和HTML <body> CSS样式找到你最喜欢的组合。例如loadHTMLString

- (void)embedYouTubeWithVideoID:(NSString *)videoID { 
    webView.backgroundColor = [UIColor clearColor]; 
    CGFloat w = webView.frame.size.width; 
    CGFloat h = webView.frame.size.height; 
    NSString *ytUrlString = [NSString stringWithFormat:@"http://www.youtube.com/v/%@&version=3&autohide=1&autoplay=1&cc_load_policy=1&fs=1&hd=1&modestbranding=1&rel=0&showsearch=0", videoID]; 
    NSString *embed = [NSString stringWithFormat:@"\ 
         <html>\ 
          <head>\ 
           <meta name=\"viewport\" content=\"initial-scale = 1.0, user-scalable = no, width = %0.0f\"/>\ 
          </head>\ 
          <body style=\"background:transparent; margin-top:0px; margin-left:0px\">\ 
           <div>\ 
            <object width=\"%0.0f\" height=\"%0.0f\">\ 
             <param name=\"movie\" value=\"%@\" />\ 
             <param name=\"wmode\" value=\"transparent\" />\ 
             <param name=\"allowFullScreen\" value=\"true\" />\ 
             <param name=\"quality\" value=\"high\" />\ 
             <embed src=\"%@\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" wmode=\"transparent\" width=\"%0.0f\" height=\"%0.0f\" />\ 
            </object>\ 
           </div>\ 
          </body>\ 
         </html>", w, w, h, ytUrlString, ytUrlString, w, h]; 
    [webView loadHTMLString:embed baseURL:nil]; 
}