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