2011-09-22 124 views
0

我想给渐变的UIWebView的背景,我加载为:iPhone:UIWebview渐变背景与CSS可能?

[self.webView loadHTMLString:customHtml baseURL:nil]; 

但这个网站行并不给出的效果,任何人都知道如何更好地做到这一点,也可以解决这个问题的CSS?

[customHtml appendString:[NSString stringWithFormat:@"%@ ", @" <body style='background-color:#4b95bf; webkit-gradient(linear, left top, left bottom, from(#55aaee), to(#003366));'>"]]; 

回答

1

的CSS是不正确webkit-gradient()不是财产,而是-webkit-gradient()是一种价值。

相反的HTML应该包含:

[customHtml appendString:[NSString stringWithFormat:@"%@ ", @" <body style='background-color:#4b95bf; background-image:-webkit-gradient(linear, left top, left bottom, from(#55aaee), to(#003366));'>"]]; 

注意-webkit-gradient之前和现在background-image:

+0

TNX但我还有一个问题,梯度只适用于可见区域,当我滚动网页流量梯度重新开始,有什么想法? – Spring

+0

请看http://stackoverflow.com/questions/7526176/iphoneuiwebview-gradient-back-ground-starts-over-when-scrolling-down-the-content – Spring