开发者

How to create a transparent web view in iphone

i m parsing an rss feed and loading it in webview..ive placed an image in the background of the webview.wat i want is a transparent webview which shows the image and also the parsed content ....below is the code..cud u guys help me out...the itemSummary contains the parsed feed

开发者_Python百科[self.itemSummary loadHTMLString:[item objectForKey:@"description"] baseURL:nil];

[self.itemSummary setClipsToBounds:YES];

self.itemSummary.opaque=NO;

self.itemSummary.backgroundColor=[UIColor clearColor];


Check this discussion:
https://discussions.apple.com/message/9175823?messageID=9175823&

Summary

Make the UIWebView transparent:

[myWebView setBackgroundColor:[UIColor clearColor]];
[myWebView setOpaque:NO];

Make the page itself transparent (use only one):

<body style="background-color: transparent">
body{background-color:transparent;}


There is a BUG in UIWebView implementation, which is misleading for many developers including readers of this thread...

If you set "backgroundColor" property to "ClearColor" and "opaque" property to "NO"(unchecked) this should've worked... But it doesn't

Then the developers look for other flags, solutions etc.

The real solution is setting the backgroundColor in code, not in IB

**

so (1) you should set "opaque" property to "NO" in IB,

and then regardless (due to the BUG) of the "backgroundColor" property you set for the WebView in IB,

you still HAVE TO (due to the BUG) (2) set the "backgroundColor" property in code, conveniently in "viewDidLoad" or "viewWillAppear"

(1) + (2) does the magic...

**

Hope this helps

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜