【开源类库学习】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 属性:确定需要修改哪些属性 事件:确定用户做哪 ...
随机推荐
- Django项目知识点汇总
目录 一.wsgi接口 二.中间件 三.URL路由系统 四.Template模板 五.Views视图 六.Model&ORM 七.Admin相关 八.Http协议 九.COOKIE 与 SES ...
- 【sgu390】数位dp
这题其实就是不断地合并子树,跟前面例一的思想是一样的. 这个打法我觉得非常优美啊(学别人的),为什么要搞lim1和lim2呢? 是因为在区间lim1~lim2之外的都是没有用的,但是我们f[h][su ...
- loj6087 毒瘤题
传送门:https://loj.ac/problem/6087 [题解] 这垃圾题目卡空间啊... k=1相信大家都会,把所有数异或起来就是答案了. 考虑k=2,把所有数异或起来得到两个答案数的异或值 ...
- 之江学院第0届校赛 qwb与支教 (容斥公式)
description qwb同时也是是之江学院的志愿者,暑期要前往周边地区支教,为了提高小学生的数学水平.她把小学生排成一排,从左至右从1开始依次往上报数. 玩完一轮后,他发现这个游戏太简单了.于是 ...
- CVE-2017-5521: Bypassing Authentication on NETGEAR Routers(Netgear认证绕过漏洞)
SpiderLabs昨天发布的漏洞, 用户访问路由器的web控制界面尝试身份验证,然后又取消身份验证,用户就会被重定向到一个页面暴露密码恢复的token.然后通过passwordrecovered.c ...
- Codeforces 940F Machine Learning 带修改莫队
题目链接 题意 给定一个长度为\(n\)的数组\(a\),\(q\)个操作,操作分两种: 对于区间\([l,r]\),询问\(Mex\{c_0,c_1,c_2,⋯,c_{10^9}\}\),其中\(c ...
- Python阶段复习 - part 1 - Python基础练习题
1.实现1-100的所有的和 # 方法1: sum = 0 for i in range(1,101): sum += i print(sum) # 方法2: num1 = int(input('请输 ...
- zabbix ZBX_NOTSUPPORTED: Timeout while executing a shell script.
有一个监控一直都是正常的,今天突然收到报警邮件,上服务器查看服务又是正常的,但是报警邮件还是没恢复 监控端进行脚本测试,发现是正常的 到监控端使用zabbix_get -s ip -p 端口 -k ...
- xpath用法(持续更新ing)
article:选取所有article元素的所有子节点 /article:选取根元素article article/a:选取所有属于article的子元素的a元素 //div:选取所有div元素 ar ...
- Tk写的发邮件小程序
from tkinter import * import smtplib from email.mime.text import MIMEText from email.header import H ...