在项目中,经常需要显示图片或者其他内容的下载进度,MBProgressHUD是一个优秀开源的进度显示控件, 方便简单,下面介绍它的使用方法
// 初始化
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;
//下载完成后,隐藏
[loadingView hide:YES];
MBProgressHUD使用方法详解
本文详细介绍如何在项目中使用MBProgressHUD作为进度显示控件,包括初始化、下载过程中的进度更新及下载完成后的隐藏操作。
984

被折叠的 条评论
为什么被折叠?



