MBProgressHUD 的用法

在项目中,经常需要显示图片或者其他内容的下载进度,MBProgressHUD是一个优秀开源的进度显示控件, 方便简单,下面介绍它的使用方法


    // 初始化

  1.   
  2. MBProgressHUD *loadingView [[[MBProgressHUD alloc]initWithView:self.view]autorelease];  
  3. loadingView.labelText @"正在加载...";  
  4. [self.view addSubview:loadingView];  
  5. [loadingView setMode:MBProgressHUDModeDeterminate];   //圆盘的扇形进度显示   
  6. loadingView.taskInProgress YES;  
  7. [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];   //显示

    //下载过程中进度
  1. NSLog(@"size:%lld,total:%lld",size,total);  
  2. downloadedBytes += size;  
  3. CGFloat progressPercent (CGFloat)downloadedBytes/total;  //计算进度   
  4. loadingView.progress progressPercent;  
            NSLog(@"size:%lld,total:%lld",size,total);
            downloadedBytes += size;
            CGFloat progressPercent = (CGFloat)downloadedBytes/total;  //计算进度
            loadingView.progress = progressPercent;

  //下载完成后,隐藏
  1. [loadingView hide:YES];  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值