码迷,mamicode.com
首页 > 移动开发 > 详细

iOS UIWebView 加载进度条的使用

时间:2017-03-25 19:07:57      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:nal   import   ram   nim   float   加载   move   for   update   

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]; ;
    

 

iOS UIWebView 加载进度条的使用

标签:nal   import   ram   nim   float   加载   move   for   update   

原文地址:http://www.cnblogs.com/xujiahui/p/6617956.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!