使用MBProgressHUD

本文详细介绍了如何在iOS项目中集成MBProgressHUD进度条库,包括下载、导入、配置及使用方法,帮助开发者轻松实现应用的加载过程可视化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、首先去https://github.com/jdg/MBProgressHUD下载包

创建项目,把包里的MBProgressHUD.h和MBProgressHUD.m源文件copy到您的项目中。

2、使用的类里面导入#import "MBProgressHUD.h"

3、在类中定义MBProgressHUD* progressTest;

创建:

progressTest = [[MBProgressHUD alloc] initWithView:self.view];  
    [self.view addSubview:progressTest];  
    [self.view bringSubviewToFront:progressTest];  
    progressTest.mode = MBProgressHUDModeIndeterminate;
    progressTest.animationType=MBProgressHUDAnimationZoom;
    progressTest.delegate = self;  
    progressTest.labelText = @"加载中...";  
    [progressTest show:YES]; 

同效:

progressTest = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    progressTest.labelText = @"加载中...";

progressTest.mode = MBProgressHUDModeIndeterminate;可以显示不同风格的进度;

typedef enum {

/** Progress is shown using an UIActivityIndicatorView. This is the default. */

MBProgressHUDModeIndeterminate,

/** Progress is shown using a round, pie-chart like, progress view. */

MBProgressHUDModeDeterminate,

/** Progress is shown using a ring-shaped progress view. */

MBProgressHUDModeAnnularDeterminate,

/** Shows a custom view */

MBProgressHUDModeCustomView,

/** Shows only labels */

MBProgressHUDModeText

} MBProgressHUDMode;

/ **显示进度使用UIActivityIndicatorView。这是默认的。 * /

/ **显示进度采用圆饼图,进步观。 * /

/**进展示出使用环形进度视图。 * /

/ **显示一个自定义视图* /

/ **仅显示标签* /


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值