iOS UIWebView 加载进度条的使用
Posted 徐家汇123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS UIWebView 加载进度条的使用相关的知识,希望对你有一定的参考价值。
1/拖到自己的??
2/ 这是 原文介绍的步骤。。但是再加入后,背景回短暂的绿色,我自己是想不要那个闪一下的状态
#import "InspectionReportViewController.h" #import "NJKWebViewProgressView.h" #import "NJKWebViewProgress.h" @interface InspectionReportViewController ()<UIWebViewDelegate,NJKWebViewProgressDelegate> { UIWebView *webview; NJKWebViewProgressView *_progressView; NJKWebViewProgress *_progressProxy; } @end @implementation InspectionReportViewController -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; //页面结束 去掉 视图 [_progressView removeFromSuperview]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. webview = [[UIWebView alloc] initWithFrame:self.view.bounds]; webview.backgroundColor = [UIColor blackColor]; [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.baidu.com]]]]; webview.scalesPageToFit = YES; webview.scrollView.scrollEnabled = NO; [self.view addSubview:webview]; _progressProxy = [[NJKWebViewProgress alloc] init]; webview.delegate = _progressProxy; _progressProxy.webViewProxyDelegate = self; _progressProxy.progressDelegate = self; CGFloat progressBarHeight = 2.f; CGRect navigationBarBounds = self.navigationController.navigationBar.bounds; CGRect barFrame = CGRectMake(0, navigationBarBounds.size.height - progressBarHeight-IPHONEHIGHT(40), navigationBarBounds.size.width, progressBarHeight); _progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame]; _progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; [webview addSubview:_progressView]; } //代理方法 #pragma mark - NJKWebViewProgressDelegate -(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress { [_progressView setProgress:progress animated:YES]; }
3/ 。在 下面这个问价中??下面??
NJKWebViewProgressView.m
//在这个方法中修改一下 -(void)configureViews{ UIColor *tintColor = [UIColor ClearColor]; // ios7 Safari bar color } //第二时这个方法中的改变 。在第二行 - (void)setProgress:(float)progress animated:(BOOL)animated { BOOL isGrowing = progress > 0.0; //下面这个方法是加进去的 _progressBarView.backgroundColor = [UIColor colorWithRed:22.f / 255.f green:126.f / 255.f blue:251.f / 255.f alpha:1.0]; ;