通过HTML代码在UIView中使用透明背景颜色 [英] Using transparent background color in UIView by HTML code

查看:169
本文介绍了通过HTML代码在UIView中使用透明背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在UIView中显示广告...我需要将背景颜色设置为透明...我尝试使用,

  [viewObject setBackgroundColor:[UIColor clearcolor]]; 

尽管它使得UIView透明,但它显示的是白色背景......



以下是我试过的HTML代码...

  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];

预先感谢...

Regards ,,

Suraj

解决方案

我不确定if我理解你的问题,但是你的HTML代码应该有一个 UIWebView 。要实现具有透明背景的UIWebView,您只需要做到以下几点:1)将UIWebView的backgroundColor属性设置为[UIColor clearColor]

2)在HTML中使用UIWebView的内容:


$ b

3)UIWebView的opaque属性设置为NO。



以上内容均摘自Apple的 TransWeb 示例代码ReadMe.txt文件。


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:transparent\"><div style=\"text-align: %@\">%@</div></body></html>",adAlignment,link]; 

Thanks in advance...

Regards,,

Suraj

解决方案

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.

这篇关于通过HTML代码在UIView中使用透明背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆