自定义UIWebView的滚动指示器

时间:2015-09-01 06:30:45

标签: ios objective-c uiwebview vertical-scrolling

我想自定义UIWebView的滚动指示符,我在UIWebView中加载本地PDF文件。我需要像这里显示的图像那样的要求。任何人都可以分享你的想法来获得这个。

scroll indicator of <code>UIWebView</code>

1 个答案:

答案 0 :(得分:2)

在WebView中有滚动视图,我们可以根据需要自定义。

UIWebView * webView = [[UIWebView alloc]initWithFrame:self.view.frame];
[self.view addSubview:webView];

UIScrollView *scrollView;
scrollView =  webView.scrollView;
scrollView.delegate = self;

还有UIScrollView Delegate 这有助于您保管ScrollView

-(void)scrollViewDidScroll:(UIScrollView *)scrollView1
{
//get refrence of vertical indicator
UIImageView *verticalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-1)]);
//set color to vertical indicator
[verticalIndicator setBackgroundColor:[UIColor redColor]];


//get refrence of horizontal indicator
UIImageView *horizontalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-2)]);
//set color to horizontal indicator
[horizontalIndicator setBackgroundColor:[UIColor blueColor]];

}