【开源类库学习】MBProgressHUD(提示框)
新博客:
MBProgressHUD是一个开源类库,实现了各种样式的提示框, 下载地址:https://github.com/jdg/MBProgressHUD,然后把两个MBProgressHUD.h和MBProgressHUD.m放到自己的项目就可以了。这里有一个小Demo可以参考一下。

头文件部分:
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h" @interface ViewController : UIViewController
{ MBProgressHUD *HUD;
} - (IBAction)showTextDialog:(id)sender; //文本提示框,默认情况下
- (IBAction)showProgressOne:(id)sender; //第一种加载提示框
- (IBAction)showProgressTwo:(id)sender; //第二种加载提示框
- (IBAction)showProgressThree:(id)sender; //第三种加载提示框
- (IBAction)showCustomDialog:(id)sender; //自定义提示框,显示打钩效果
- (IBAction)showAllTextDialog:(id)sender; //显示纯文本提示框 @end
实现文件部分
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (IBAction)showTextDialog:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD]; HUD.dimBackground = YES; //把当前的view置于后台
HUD.labelText = @"请稍等"; //显示对话框
[HUD showAnimated:YES whileExecutingBlock:^{ sleep();
} completionBlock:^{
}];
} - (IBAction)showProgressOne:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD]; HUD.labelText = @"正在加载";
HUD.mode = MBProgressHUDModeDeterminate;
//HUD.mode = MBProgressHUDModeAnnularDeterminate;
[HUD showAnimated:YES whileExecutingBlock:^{ float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep();
}
} completionBlock:^{
[HUD removeFromSuperview];
[HUD release];
HUD = nil; }];
} - (IBAction)showProgressTwo:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD]; HUD.labelText = @"正在加载";
HUD.mode = HUD.mode = MBProgressHUDModeAnnularDeterminate;
[HUD showAnimated:YES whileExecutingBlock:^{ float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep();
}
} completionBlock:^{
[HUD removeFromSuperview];
[HUD release];
HUD = nil; }]; } - (IBAction)showProgressThree:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD]; HUD.labelText = @"正在加载";
HUD.mode = MBProgressHUDModeDeterminateHorizontalBar;
[HUD showAnimated:YES whileExecutingBlock:^{ float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep();
}
} completionBlock:^{
[HUD removeFromSuperview];
[HUD release];
HUD = nil; }]; } - (IBAction)showCustomDialog:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD]; HUD.labelText = @"操作成功";
HUD.mode = MBProgressHUDModeCustomView;
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Checkmark"]] autorelease];
[HUD showAnimated:YES whileExecutingBlock:^{
sleep();
} completionBlock:^{
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}];
} - (IBAction)showAllTextDialog:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD]; HUD.labelText = @"操作成功";
HUD.mode = MBProgressHUDModeText;
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Checkmark"]] autorelease];
[HUD showAnimated:YES whileExecutingBlock:^{
sleep();
} completionBlock:^{
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}]; } - (void)dealloc { [super dealloc];
}
@end
实现效果如图所示:
1、默认效果,也就是MBProgressHUDModeIndeterminate

2、第一种加载提示框,MBProgressHUDModeDeterminate

3、第二种加载提示MBProgressHUDModeAnnularDeterminate

4、第三种加载提示框,MBProgressHUDModeDeterminateHorizontalBar

5、自定义提示框 ,可以带图片的MBProgressHUDModeCustomView

6.纯文本提示框

如果有什么问题,欢迎通过微博交流 @Linux_小木头
【开源类库学习】MBProgressHUD(提示框)的更多相关文章
- 【转】IOS学习笔记29—提示框第三方库之MBProgressHUD
原文网址:http://blog.csdn.net/ryantang03/article/details/7877120 MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单 ...
- 【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果
原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单.方便,并且可以对显 ...
- [原]发布一个jQuery提示框插件,Github开源附主站,jquery.tooltips.js
一个简单精致的jQuery带箭头提示框插件 插件写好快一年了,和一个 弹出框插件(点击查看) 一起写的,一直没有整理出来,昨天得功夫整理并放到了github上,源码和网站均可在线看或下载. CSS中的 ...
- Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog)
Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog) Android第三方开源对话消息提示框:SweetAlertDialog(sweet- ...
- 精美舒适的对话消息提示框--第三方开源--SweetAlertDialog
SweetAlertDialog(sweet-alert-dialog)是一个套制作精美.动画效果出色生动的Android对话.消息提示框 SweetAlertDialog(sweet-alert-d ...
- iOS提示框,为什么你应该使用 MBProgressHUD?
这是一篇带有一定笔者主观感情色彩的比较文章.文章着重对比github上最流行的两个iOS进度提示控件 MBProgressHUD 与 SVProgressHUD的各自优劣,来帮助初学者找到一个适合的i ...
- JS学习笔记 -- 定时器,提示框的应用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Android应用开发学习之Toast消息提示框
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 本文我们来看Toast消息提示框的用法.使用Toast消息提示框一般有三个步骤: 1. 创建一个Toast对象.可 ...
- 【JS学习笔记】第一个JS效果——鼠标提示框
分析效果实现原理--鼠标提示框 样式:div的display 事件:onmouseover,onmouseout 编写JS的流程 布局:HTML+CSS 属性:确定需要修改哪些属性 事件:确定用户做哪 ...
随机推荐
- HDU1385 (Floyd记录路径)
Minimum Transport Cost Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- JAVA 开发工具 市场状况
转载:http://blog.csdn.net/hj7jay/article/details/52250755 2016 JAVA 流行的开发工具 最流行的工具并不一定是“最好的”,对于开发来说,什么 ...
- Python3安装cx_Oracle连接oracle数据库实操总结
弄清版本,最重要!!! 首先安装配置时,必须把握一个点,就是版本一致!包括:系统版本,python版本,oracle客户端的版本,cx_Oracle的版本,然后安装配置就容易了! 如果已经安装Pyth ...
- 【LYOI2016】EasyRound1
这可能是给新高一写的吧……随手写着玩玩…… A:随便模拟 #include<cstdio> #include<cstring> using namespace std; int ...
- 使用div实现progress进度条
在百度上搜了很多方法去修改HTML5 progress的样式,然而并没有实现. 所以自己用div实现了一个. 简单粗暴(*^-^*) 可以在CSS里改样式,可以JS里改进度. <div cla ...
- 多个springboot项目部署在同一tomcat上,出现jmx错误
多个springboot项目部署在同一tomcat上,出现jmx错误 原因:因为jmx某些东西重复,禁用jmx就可以了 endpoints.jmx.unique-names=true
- C# 日期格式化{0:yyyy-MM-dd HH:mm:ss.fff}和{0:yyyy-MM-dd hh:mm:ss.fff}的区别(转)
日期格式化{0:yyyy-MM-dd HH:mm:ss.fff}和{0:yyyy-MM-dd hh:mm:ss.fff}的区别http://www.cnblogs.com/jhxk/articles/ ...
- Ubuntu-16.04安装Xdebug-2.2.5及相关介绍
Xdebug是一个开放源代码的PHP程序调试器(即一个Debug工具),可以用来跟踪,调试和分析PHP程序的运行状况.在日常开发中,我们会使用如 print_r() var_dump()等函数来进行调 ...
- 【互动问答分享】第11期决胜云计算大数据时代Spark亚太研究院公益大讲堂
Q1:docker成熟度如何? Docker是2013年和2014年最火爆的云计算开源项目: Baidu公司是中国使用Docker最为深入和最大规模的公司,线上稳定运行数十万个Docker容器,目前已 ...
- vs2008下Error LINK2005: already defined in ...的一种解决方式
原因:不同的库之间都定义了相同的名称. 方法:右键工程->Properties->Configuration->Linker->Input 在右侧的Additional Dep ...