让UIWebView的背景透明:
1 2 | self .webView.backgroundColor = [ UIColor clearColor ]; self .webView.opaque = NO |
这样就可以背景透明了,如果还是无效的话,那么需要在html里面加入:
<body style="background-color: transparent">
去掉uiwebview滚动到边缘时的阴影效果:(不要重复对一个uiwebview调用这个方法,会导致滚动条消失)
1 2 3 4 5 6 7 8 9 10 11 12 | - ( void ) hideGradientBackground :( UIView *)theView { for ( UIView * subview in theView.subviews) { if ([subview isKindOfClass :[ UIImageView class ]]) subview.hidden = YES ; [ self hideGradientBackground :subview]; } } - ( void )viewDidLoad { [ self hideGradientBackground : self .webView]; } |
去除copy/paste的响应:
1 | [webView stringByEvaluatingJavaScriptFromString : @ "var css = document.createElement(\"style\");css.type = \"text/css\";css.innerHTML = \"* {-webkit-touch-callout: none;-webkit-user-select: none;}\";document.body.appendChild(css);" ];
|