【开源类库学习】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 属性:确定需要修改哪些属性 事件:确定用户做哪 ...
随机推荐
- Ubuntu下kafka集群环境搭建及测试
kafka介绍: Kafka[1是一种高吞吐量[2] 的分布式发布订阅消息系统,有如下特性: 通过O(1)的磁盘数据结构提供消息的持久化,这种结构对于即使数以TB的消息存储也能够保持长时间的稳定性能 ...
- MySQL实现分页查询
imit 基本实现方式 一般情况下,客户端通过传递 pageNo(页码).pageSize(每页条数)两个参数去分页查询数据库中的数据,在数据量较小(元组百/千级)时使用 MySQL自带的 limit ...
- bzoj 1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居——排序+贪心+set
Description 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发现她们已经结成了几个“群”.每只奶牛在吃草的时候有一个独一无二的位置坐标Xi,Yi(l ...
- ThinkPHP 多应用多模块建立方式
ThinkPHP3.2.2及以后版本同一应用多模块和多应用多模块的设计已经比以前的版本更加简单快捷. 注:入口文件为index.php,内容为: <?php // +-------------- ...
- bzoj 2659 几何
首先考虑(0, 0)到(p, q)这条直线. y = q / p * x. sum{k = 0 to (p - 1) / 2} [q / p * k] 就是直线下方的点数.sum{k = 0 to ( ...
- Codeforces 362E Petya and Pipes 费用流建图
题意: 给一个网络中某些边增加容量,增加的总和最大为K,使得最大流最大. 费用流:在某条边增加单位流量的费用. 那么就可以2个点之间建2条边,第一条给定边(u,v,x,0)这条边费用为0 同时另一条边 ...
- String类的常见方法的使用案例
String类的常见方法的使用案例 //使用指定的字符串替换当前字符串中指定的内容 //将helloworld中的o替换为a String s="HelloWorld"; Stri ...
- JSTL c:url
c:url 标签 jstl 实例代码和用法. <c:url>标记格式化成一个字符串格式的URL,并将其存储到变量中.这个标签会在必要时自动执行URL重写. var属性指定的变量将包 ...
- krpano--控制热点跳转到场景的指定视角
krpano课堂(肥宗) · 2015-07-13 19:32 有这么一种情况,假设我们用三个场景,这三个场景恰好是一条街道的同一方向的三个拍摄点.如上图. 我们可以通过设置A.B.C三个场景中的vi ...
- HDU 6330.Problem L. Visual Cube-模拟到上天-输出立方体 (2018 Multi-University Training Contest 3 1012)
6330.Problem L. Visual Cube 这个题就是输出立方体.当时写完怎么都不过,后来输出b<c的情况,发现这里写挫了,判断失误.加了点东西就过了,mdzz... 代码: //1 ...