MBProgressHUD的基本使用
和gitHub上的Demo其实差不多,就是小整理了下,当备忘,想做复杂的效果可以参考MBProgressHUD在gitHub上的DEMO,写得也很清楚明了。
先下载MBProgressHUD.h和.m文件,拖入工程。地址:MBProgressHUD
以下是代码:(先在.h文件里定义 MBProgressHUD *HUD;)
- //方式1.直接在View上show
- HUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain];
- HUD.delegate = self;
- //常用的设置
- //小矩形的背景色
- HUD.color = [UIColor clearColor];//这儿表示无背景
- //显示的文字
- HUD.labelText = @"Test";
- //细节文字
- HUD.detailsLabelText = @"Test detail";
- //是否有庶罩
- HUD.dimBackground = YES;
- [HUD hide:YES afterDelay:2];
- //只显示文字
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- hud.mode = MBProgressHUDModeText;
- hud.labelText = @"Some message...";
- hud.margin = 10.f;
- hud.yOffset = 150.f;
- hud.removeFromSuperViewOnHide = YES;
- [hud hide:YES afterDelay:3];
- //方式2.initWithView
- //use block
- HUD = [[MBProgressHUD alloc] initWithView:self.view];
- [self.view addSubview:HUD];
- HUD.labelText = @"Test";
- [HUD showAnimated:YES whileExecutingBlock:^{
- NSLog(@"%@",@"do somethings....");
- [self doTask];
- } completionBlock:^{
- [HUD removeFromSuperview];
- [HUD release];
- }];
- //圆形进度条
- HUD = [[MBProgressHUD alloc] initWithView:self.view];
- [self.view addSubview:HUD];
- HUD.mode = MBProgressHUDModeAnnularDeterminate;
- HUD.delegate = self;
- HUD.labelText = @"Loading";
- [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
- //自定义view
- HUD = [[MBProgressHUD alloc] initWithView:self.view];
- HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
- // Set custom view mode
- HUD.mode = MBProgressHUDModeCustomView;
- HUD.delegate = self;
- HUD.labelText = @"Completed";
- [HUD show:YES];
- [HUD hide:YES afterDelay:3];
代理方法:
- #pragma mark -
- #pragma mark HUD的代理方法,关闭HUD时执行
- -(void)hudWasHidden:(MBProgressHUD *)hud
- {
- [hud removeFromSuperview];
- [hud release];
- hud = nil;
- }
二个task
- -(void) doTask{
- //你要进行的一些逻辑操作
- sleep(2);
- }
- -(void) myProgressTask{
- float progress = 0.0f;
- while (progress < 1.0f) {
- progress += 0.01f;
- HUD.progress = progress;
- usleep(50000);
- }
- }
MBProgressHUD的基本使用的更多相关文章
- MBProgressHud添加自定义动画
在使用自定义view时,若直接使用,如下 MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud ...
- IOS MBProgressHUD的使用
一,简介 苹果的应用程序一般都会用一种优雅的,半透明的进度显示效果,不过这个API是不公开的,因此你要是用了,很可能被清除出AppStore.而 MBProgressHUD提供了一个替 ...
- iOS基于MBProgressHUD的二次封装,一行搞定,使用超简单
MBProgressHUD的使用,临时总结了几款最常用的使用场景: 1.提示消息 用法: [YJProgressHUD showMessage:@"显示文字,1s隐藏" inVie ...
- MBProgressHUD上传照片进度提示
第一步,控制器先来个属性 @property (strong, nonatomic) MBProgressHUD *HUD; 第二步,显示与隐藏的调用方法 - (void)hudTipWillShow ...
- MBProgressHUD+FastCall
+ (void)showHudTipStr:(NSString *)tipStr; + (void)showHudTipStr:(NSString *)tipStr{ ) { MBProgressHU ...
- MBProgressHUD框架的使用:https://github.com/jdg/MBProgressHUD
MBProgressHUD是一个开源类库,实现了各种样式的提示框, 下载地址:https://github.com/jdg/MBProgressHUD,然后把两个MBProgressHUD.h和MBP ...
- MBProgressHUD使用
//方式1.直接在View上show HUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain]; HUD.delegat ...
- MBProgressHUD.h file not found
MBProgressHUD框架,怎么我导入MBProgressHUD+MJ.h会报错.(即MBProgressHUD+MJ根本不存在),我看其他人的视屏又可以导入 MBProgressHUD.h fi ...
- 【转】IOS学习笔记29—提示框第三方库之MBProgressHUD
原文网址:http://blog.csdn.net/ryantang03/article/details/7877120 MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单 ...
- MBProgressHUD 扩展加载动画
效果图: 设计给了一个组的图片,但是由于是透明的背景,会产生卡顿,其实只要两张图片就可以了 创建一个 MBProgressHUD 分类 增加方法 + (MB_INSTANCETYPE)myShowHU ...
随机推荐
- Delphi中文本文件的操作
Delphi中文本文件的操作 相关知识内容: 在对文本文件进行任何处理之前,首先要打开此文本文件.声明变量:通过此变量可以来引用一个文本文件. 打开一个文件需要两步:首先是 AssignFile(), ...
- linux常用命令2
1.top 最近自己最常用的是 top d -1(每秒刷新一次) 主要看Mem used使用内存:CPU idle 剩余CPU:CPMMAND进程:以及%CPU进程所占用CPU. 目前主要是系统出问题 ...
- Understanding the Android Life Cycle
Problem Android apps do not have a “main” method; you need to learn how they get started and how the ...
- 设计模式学习--复合模式(Compound Pattern)
设计模式学习--复合模式(Compound Pattern) 概述 ——————————————————————————————————————————————————— 2013年8月4日<H ...
- SWIFT国际资金清算系统
SWIFT又称:“环球同业银行金融电讯协会”,是国际银行同业间的国际合作组织,成立于一九七三年,目前全球大多数国家大多数银行已使用SWIFT系统.SWIFT的使用,使银行的结算提供了安全.可靠.快捷. ...
- android中画文字的换行 办法(对于遇到canvas.drawText(String s )无法实现换行问题的解决)
在使用canvas.drawText()绘制文字的时候,发现,如果需要绘制的文字较长,需要换行,通过在文字中加上“\n"或者”\r\n"都无法实现换行,如果非要使用canvas.d ...
- 持久化API(JPA)系列(三)实体Bean的开发技术-建立与数据库的连接
在EJB 2.x中.EJB有3种类型的Bean.各自是会话Bean(Session Bean).消息驱动Bean(Message-Driven Bean)和实体Bean(Entity Bean). 随 ...
- C++标准库之 Lower_Bound, upper_Bound
关于二分查找,这绝对是最简单却又最难的实现了,其各种版本号能够參见http://blog.csdn.net/xuqingict/article/details/17335833 在C++的标准库中,便 ...
- SVN经常使用命令说明
SVN版本号:1.5 及更新版本号 名词说明: WC:Working Copy 你的工作区 Versioned:受控的:受版本号控制的 SVN是什么? SVN是开源的版本号控制系统. 比CVS很多其它 ...
- Java基础知识强化95:Calendar类之Calendar类的add()和set()方法
1. Calendar的add()和set()方法: public void add(int field,int amount):根据给定的日历字段和对应的时间,来对当前的日历进行操作 public ...