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 ...
随机推荐
- Silverlight 模板(Template)使用
模板(Template)是控件另一种样式 它和样式(style)不同的是它允许已有的控件进行组合新的一个控件样式 那么先看一下最简单Template代码 xaml代码 <Button Conte ...
- Java---IO加强(1)
RandomAccessFile ★随机访问文件,自身具备读写的方法. new RandomAccessFile()之后,若文件不存在会自动创建,存在则不创建.--该类其实内部既封装了字节输入流,又封 ...
- 【转】silverlight 跨域访问
作者:MIDI 来源:博客园 发布时间:2010-01-01 17:39 阅读:204 次 原文链接 [收藏] 在 Silverlight 使用 WebService .WCF.We ...
- Java学习日记 I/O
File类1.String[] list() 返回一个目录下文件和文件夹路径的字符串数组2.File[] listFiles() 以File类对象数组,返回目录下的所有文件和文件夹3.isDirect ...
- Linux操作系统以及各大发行版介绍——Linux operating system and major distribution is introduced
什么是Linux? 也许很多人会不屑的说,Linux不就是个操作系统么.错!Linux不是一个操作系统,严格来讲,Linux只是一个操作系统中的内核.内核是什么?内核建立了计算机软件与硬件之间通讯的平 ...
- java排序算法-选择排序
public class SelectionSort { private static void selectSortTest() { int[] sortArray = { 5, 2, 4, 1, ...
- Runtime.exec()
关于RunTime类的介绍: /** * Every Java application has a single instance of class * <code>Runtime< ...
- Resizable 2th click not working
here's a simple solution. just destroy the resizable function, then rebuild it. try { $("#div& ...
- vmware workstation11虚拟机破解版(附安装教程) 32/64位
http://kuai.xunlei.com/d/ru4IAALVJQBesH9U93e?p=20395 vmware workstation 11注册机是一款可以免费生成vmware11.0版本序列 ...
- cocos2d-x 3.6版连连看载入资源
网上找了一个梦幻连连看的资源.大家能够百度一下.然后整理一下加到project里面去.包含声音和图片文件.后面解释怎样整理能够方便管理. 我不推荐在代码里面直接引用资源文件名称,我称之为硬编码. 做i ...