开发者

Using transparent background color in UIView by HTML code

开发者 https://www.devze.com 2023-02-12 07:12 出处:网络
I\'m trying to display an ad in UIView... I need to set the background color to transparent... I tried using,

I'm trying to display an ad in UIView... I need to set the background color to transparent... I tried using,

[viewObject setBackgroundColor:[UIColor clearcolor]]; 

Eventhough it made the UIView transparent, it is displaying white background...

Below is the HTML code I tried...

NSString *HTML = [NSString stringWithFormat:@"<html><head><meta name=\"viewport\" content=\"width=device-width, user-scalable=no\"/><style>*{margin:0px;padding:0px}</style>
</head><body style=\" background-color:tra开发者_如何学Gonsparent\"><div style=\"text-align: %@\">%@</div></body></html>",adAlignment,link]; 

Thanks in advance...

Regards,,

Suraj


Did you also set opaque = NO; on the view?


I'm not sure if I understood your question, but you should have a UIWebView for your HTML code. To implement a UIWebView with a transparent background all you need to do is

1) set the UIWebView's backgroundColor property to [UIColor clearColor]

2) use the UIWebView's content in the html:

3) the UIWebView's opaque property set to NO.

The above are taken verbatim from Apple's TransWeb sample code ReadMe.txt file.


Your window color is white.clear this.

window.backgroundColor = [UIColor clearColor];

0

精彩评论

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