iOS之webview进度条控件NJKWebViewProgress的使用
来源:互联网 发布:淘宝品质退款率怎么降 编辑:程序博客网 时间:2024/06/06 00:41
首先说下下载地址:
NJKWebViewProgress地址:https://github.com/ninjinkun/NJKWebViewProgress
直接上代码:
#import "ViewController.h"#import "NJKWebViewProgressView.h"@implementation ViewController{ UIWebView *_webView; NJKWebViewProgressView *_progressView; NJKWebViewProgress *_progressProxy;}- (void)viewDidLoad{ [super viewDidLoad]; //设置webview _webView = [[UIWebView alloc]init]; _webView.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); [self.view addSubview:_webView]; _webView.dataDetectorTypes = UIDataDetectorTypeNone;//关闭自动检测网页上的电话号码 _webView.scalesPageToFit = YES;//自动对页面进行缩放以适应屏幕 //设置进度条 _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, navigationBarBounds.size.width, progressBarHeight); _progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame]; _progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; [self loadwebview];}- (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController.navigationBar addSubview:_progressView];}-(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; // Remove progress view // because UINavigationBar is shared with other ViewControllers [_progressView removeFromSuperview];}-(void)loadwebview{ NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://www.baidu.com/"]]; [_webView loadRequest:req];}#pragma mark - NJKWebViewProgressDelegate-(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress{ [_progressView setProgress:progress animated:YES]; //self.title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];}@end
阅读全文
0 0
- iOS之webview进度条控件NJKWebViewProgress的使用
- IOS 使用NJKWebViewProgress做webview加载进度条
- iOS 使用NJKWebViewProgress做webview进度条
- iOS 使用NJKWebViewProgress做webview进度条
- iOS 使用NJKWebViewProgress做webview进度条
- iOS 使用NJKWebViewProgress做webview进度条
- iOS 使用NJKWebViewProgress做webview进度条
- UIWebView 进度条控件 NJKWebViewProgress的使用和分析
- iOS 网页进度条 NJKWebViewProgress
- UIWebView 加载进度控件 NJKWebViewProgress的使用
- ios 之webview的使用
- 加载进度条显示 NJKWebViewProgress
- 高级控件之进度条的使用
- ios webview 进度条展示(二)使用
- ios webview 进度条的展示(一)
- iOS学习之WebView的使用
- iOS学习之WebView的使用
- iOS学习之WebView的使用
- laravel5.4 把excal的数据上传到数据库的操作
- win10 配置java环境变量
- echarts 横向圆角条状图
- Vue豆瓣系列文章
- 题目1004:Median 2011年浙江大学计算机及软件工程研究生机试真题
- iOS之webview进度条控件NJKWebViewProgress的使用
- 设置NPM淘宝代理镜像
- 当 better-scroll 遇见 Vue
- 【LeetCode】 31. Next Permutation
- Android 怎么退出整个应用程序?
- Vue-book 2.0 一个移动端简单的全栈 web APP
- 构造(Virtual Participation,HDU 5334)
- windows平台如何装win7系统
- Vue全家桶+Mint-Ui打造高仿QQMusic,搭配详细说明