iOS 使用NJKWebViewProgress做webview进度条
2015-12-18 10:21
525 查看
NJKWebViewProgress地址:https://github.com/ninjinkun/NJKWebViewProgress
导入头文件
#import "NJKWebViewProgressView.h" #import "NJKWebViewProgress.h"
遵守协议
<UIWebViewDelegate, NJKWebViewProgressDelegate>
实现代码
@implementation ViewController { IBOutlet __weak UIWebView *_webView; NJKWebViewProgressView *_webViewProgressView; NJKWebViewProgress *_webViewProgress; } - (void)viewDidLoad { [super viewDidLoad]; _webViewProgress = [[NJKWebViewProgress alloc] init]; _webView.delegate = _webViewProgress; _webViewProgress.webViewProxyDelegate = self; _webViewProgress.progressDelegate = self; CGRect navBounds = self.navigationController.navigationBar.bounds; CGRect barFrame = CGRectMake(0, navBounds.size.height - 2, navBounds.size.width, 2); _webViewProgressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame]; _webViewProgressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; [_webViewProgressView setProgress:0 animated:YES]; [self loadBaidu]; [self.navigationController.navigationBar addSubview:_webViewProgressView]; } -(void)loadBidu { NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.baidu.com/"]]; [_webView loadRequest:req]; } #pragma mark - NJKWebViewProgressDelegate -(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress { [_webViewProgressView setProgress:progress animated:YES]; self.title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"]; }
相关文章推荐
- Retrieving File Information
- Setting Up File Sharing
- Android 监听键盘的弹起与收缩
- Android ListView下拉/上拉刷新:设计原理与实现
- 微信公众平台认证步骤详解及服务号和订阅号区别---之微信开发一
- iOS TPKeyboardAvoiding自动识别键盘的高度
- 原生js实现移动端瀑布流式代码示例
- (亲测有效)Android SDK Manager国内无法更新的解决方案
- IOS视频分解图片、图片合成视频
- android---------Android中通过注解代替findViewById方法
- Objective-C_语言_NSDate(时间类型)和NSCalendar(日历)NSTimeZone(时区)
- 教你一招:ios app内部直接调用系统设置页面
- swift学习记录(闭包)
- Android中如何实现textView图文混排
- android6.0功能添加,QC3.0
- Android编程实现手绘及保存为图片的方法(附demo源码下载)
- iOS-swift-动画 简单基础的动画摘要-1
- Swift -- 函数的使用(函数作为参数、返回值、嵌套函数)
- ios启动程序时隐藏状态栏,启动后显示状态栏的方法
- App在iOS9上不能分享至微信,提示微信没有安装