我有一个应用程序,每一行都有一个UITableView
和一个对应的详细视图。在细节视图中,我必须显示一些文本和背景图像(每行的文本不同,但图像保持不变)。在我看来,最简单的方法是将文本放在.rtf文件中,并在UIWebView
中显示它。然后只需在UIWebView
后面放一个UIImageView
。
我试着在IB中将UIWebView
的不透明度设置为零,但没有帮助。
你能帮帮我吗?
发布于 2011-09-28 05:15:42
使用下面的递归方法从UIWebView中删除渐变:
[webView setBackgroundColor:[UIColor clearColor]];
[self hideGradientBackground:webView];
- (void) hideGradientBackground:(UIView*)theView
{
for (UIView * subview in theView.subviews)
{
if ([subview isKindOfClass:[UIImageView class]])
subview.hidden = YES;
[self hideGradientBackground:subview];
}
}
发布于 2014-06-17 04:41:21
Swift更新:
webView.opaque = true
webView.backgroundColor = UIColor.clearColor()
再说一次,不要忘记设置
<body style="background-color: transparent">
或者更好的做法是,在样式表中使用内联样式:
body {
background-color: transparent
}
发布于 2013-06-28 10:38:05
我可以通过转到“属性检查器”并取消选中“绘制不透明”来使我的UIWebView透明。
我的HTML代码仅供参考。
UIWebView* webView =(UIWebView *) [cell viewWithTag:100];
NSString* htmlContentString = [NSString stringWithFormat:
@"<html>"
"<style type='text/css'>html,body {margin: 0;padding: 0;width: 100%%;height: 100%%;}</style>"
"<body>"
"<table style='border:1px solid gray; border-radius: 5px; overflow: hidden;color:white;font-size:10pt' cellspacing=\"0\" cellpadding=\"1\" align='right'><tr>"
"<td>Hello</td><td>There</td>"
"</tr></table>"
"</body></html>"
];
[webView loadHTMLString:htmlContentString baseURL:nil];
https://stackoverflow.com/questions/3646930
复制相似问题