3k

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

UIWebView 一些设置

Posted on 2012-08-03 17:30  3k  阅读(320)  评论(0)    收藏  举报
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; } } } }

3.UIWebView加载本地html

// get html file path NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]; [webView_ loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];

4.禁用UIWebView拖拽时的反弹效果

// disable view bounce [(UIScrollView *)[[webView_ subviews] objectAtIndex:0] setBounces:NO];

5.禁用UIWebView拖拽

// disable touch move <script type="text/javascript"> document.ontouchmove = function(e) { e.preventDefault(); } </script>