您的位置:首页 > 移动开发

UIWebView背景透明且无拖拽后的上下阴影

2014-02-08 00:29 197 查看
1.首先UIWebView背景透明
// set background transparent, also can set it in nib file
webView_.backgroundColor = [UIColor clearColor];
webView_.opaque = NO;


2.隐藏拖拽webview时上下的两个有阴影效果的subview
// remove shadow view when drag web view
for (UIView *subView in [webView_ subviews]) {
if ([subView isKindOfClass:[UIScrollView class]]) {
for (UIView *shadowView in [subView subviews]) {
if ([shadowView isKindOfClass:[UIImageView class]]) {
shadowView.hidden = YES;
}
}
}
}


其他

a.UIWebView加载本地html
// get html file path
NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"];
[webView_ loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];


b.禁用UIWebView拖拽时的反弹效果
// disable view bounce
[(UIScrollView *)[[webView_ subviews] objectAtIndex:0] setBounces:NO];


c.禁用UIWebView拖拽
// disable touch move
<script type="text/javascript">
document.ontouchmove = function(e) {
e.preventDefault();
}
</script>

转自: http://blog.lanceli.com/2011/09/uiwebview-background-transparent.html[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UIWebView