在项目中,经常需要显示图片或者其他内容的下载进度,MBProgressHUD是一个优秀开源的进度显示控件, 方便简单,下面介绍它的使用方法
-
- MBProgressHUD
*loadingView = [[[MBProgressHUD alloc]initWithView:self.view]autorelease]; - loadingView.labelText
= @"正在加载..."; - [self.view
addSubview:loadingView]; - [loadingView
setMode:MBProgressHUDModeDetermi nate]; //圆盘的扇形进度显示 - loadingView.taskInProgress
= YES; - [loadingView
show:YES]; //显示
MBProgressHUD *loadingView = [[[MBProgressHUD alloc]initWithView:self.view]autorelease]; loadingView.labelText = @"正在加载..."; [self.view addSubview:loadingView]; [loadingView setMode:MBProgressHUDModeDeterminate]; //圆盘的扇形进度显示 loadingView.taskInProgress = YES; [loadingView show:YES]; //显示
- NSLog(@"size:%lld,total:%lld",size,total);
- downloadedBytes
+= size; - CGFloat
progressPercent = (CGFloat)downloadedBytes/total; //计算进度 - loadingView.progress
= progressPercent;
NSLog(@"size:%lld,total:%lld",size,total); downloadedBytes += size; CGFloat progressPercent = (CGFloat)downloadedBytes/total; //计算进度 loadingView.progress = progressPercent;
- [loadingView
hide:YES];