Using transparent background color in a UIView using HTML

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

[viewObject setBackgroundColor:[UIColor clearcolor]]; 

Although this made the UIView transparent, it displays a 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:transparent\"><div style=\"text-align: %@\">%@</div></body></html>",adAlignment,link]; 

Thanks in advance...

Yours faithfully,

Suraj

+4
source share
3 answers

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, you only need to

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

2) use the contents of the UIWebView in html:

3) the opacity property of UIWebView is set to NO.

The above words are taken from Apple TransWeb sample file ReadMe.txt.

+4
source

You also set opaque = NO; in view?

+5
source

The color of your window is white. Explain it.

window.backgroundColor = [UIColor clearColor];

+1
source

Source: https://habr.com/ru/post/1340761/


All Articles