UIWebView
_entryWebView = [[UIWebView alloc]init];
_entryWebView.backgroundColor = [UIColorcolorWithRed:240/255.0green:240/255.0blue:240/255.0alpha:1];
_entryWebView.userInteractionEnabled = YES;
[selfsetWebViewBackgroundColor];
_entryWebView.delegate = self;
[self.viewaddSubview:_entryWebView];
for (UIView *aView in [_entryWebView subviews])
{
if ([aView isKindOfClass:[UIScrollView class]])
{
//水平的滚动条
[(UIScrollView *)aView setShowsHorizontalScrollIndicator:NO];
for (UIView *shadowView in aView.subviews)
{
if ([shadowView isKindOfClass:[UIImageView class]])
{
shadowView.hidden = YES; //上下滚动出边界时的黑色的图片也就是拖拽后的上下阴影
}
}
}
}
UIWebView默认允许当网页内容处于最顶端时,用户用手指往下拖动,然后露出空白的背景。这份代码能够禁止这种效果。
//Before iOS 5
for (id subview in webView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).bounces = NO;
//After iOS 5
webView.scrollView.bounces = NO;
//该片段来自于http://outofmemory.cn

浙公网安备 33010602011771号