原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html

MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单、方便,并且可以对显示的内容进行自定义,功能很强大,很多项目中都有使用到。到GitHub上可以下载到项目源码https://github.com/jdg/MBProgressHUD,下载下来后直接把MBProgressHUD.h和MBProgressHUD.m拖入工程中就行,别忘了选择拷贝到工程。完了在需要使用的地方导入头文件就可以开始使用了。首先看下工程截图: 
 
接下来是整个Demo的完整界面,这里我只选择出了几个常用的对话框,其他样式的在源码提供的Demo里可以找到,要用的话直接参考就可以。 
 
接下来直接上代码了,头文件部分:

#import <UIKit/UIKit.h>
#import "MBProgressHUD.h" @interface ViewController : UIViewController
{
//HUD(Head-Up Display,意思是抬头显示的意思)
MBProgressHUD *HUD;
} - (IBAction)showTextDialog:(id)sender;
- (IBAction)showProgressDialog:(id)sender;
- (IBAction)showProgressDialog2:(id)sender;
- (IBAction)showCustomDialog:(id)sender;
- (IBAction)showAllTextDialog:(id)sender; @end

实现文件(按钮实现部分):

- (IBAction)showTextDialog:(id)sender {
//初始化进度框,置于当前的View当中
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD]; //如果设置此属性则当前的view置于后台
HUD.dimBackground = YES; //设置对话框文字
HUD.labelText = @"请稍等"; //显示对话框
[HUD showAnimated:YES whileExecutingBlock:^{
//对话框显示时需要执行的操作
sleep(3);
} completionBlock:^{
//操作执行完后取消对话框
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}];
} - (IBAction)showProgressDialog:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.labelText = @"正在加载"; //设置模式为进度框形的
HUD.mode = MBProgressHUDModeDeterminate;
[HUD showAnimated:YES whileExecutingBlock:^{
float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep(50000);
}
} completionBlock:^{
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}];
} - (IBAction)showProgressDialog2:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.labelText = @"正在加载";
HUD.mode = MBProgressHUDModeAnnularDeterminate; [HUD showAnimated:YES whileExecutingBlock:^{
float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep(50000);
}
} 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(2);
} 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; //指定距离中心点的X轴和Y轴的偏移量,如果不指定则在屏幕中间显示
// HUD.yOffset = 150.0f;
// HUD.xOffset = 100.0f; [HUD showAnimated:YES whileExecutingBlock:^{
sleep(2);
} completionBlock:^{
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}];
}

依次实现的效果如下: 
 
下面这个效果就类似Android中的Toast: 
 
以上就简单介绍了MBProgressHUD的使用,这里都是采用block的形式来操作的,这样写起代码来更直观也更高效。

以上就是提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果的全文介绍,希望对您学习和使用ios应用开发有所帮助.

【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果的更多相关文章

  1. 【转】IOS学习笔记29—提示框第三方库之MBProgressHUD

    原文网址:http://blog.csdn.net/ryantang03/article/details/7877120 MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单 ...

  2. 安装需要的第三方库时,命令行输入pip提示不是内部或外部命令

    简介 在做Python开发时,安装需要的第三方库时,大多数人喜欢选择在命令行用pip进行安装. 然而有时敲入pip命令会提示‘pip’不是内部或外部命令..如图: 解决办法 1.在python安装目录 ...

  3. IOS 第三方库之-MBProgressHUD的使用详解

    转自作者: weidfyr  http://www.aiuxian.com/article/p-3121607.html 1,MBProgressHUD常用属性和用法Demo - (void)test ...

  4. iOS 学习笔记 十三 (2015.04.15)采用第三方库,实现ios录音转为amr

    1.第三方开源库地址 https://github.com/guange2015/ios-amr 2.参考博客地址 http://blog.csdn.net/windsoul85/article/de ...

  5. cocoapods导入第三方库后,xcode上import不提示,找不到第三方库的解决办法

    选择你的工程tagets, -> Build Settings -> Search Paths -> User Header Search Paths 双击User Header S ...

  6. iOS,第三方库使用

    1.ASIHttpRequest网络请求库 2.MBProgressHUD指示层库 3.Toast+UIView提示库 4.SDWebImage图片缓存库 5.MGSwipeTableCell单元格侧 ...

  7. iOS 第三方库、插件、知名博客总结

    iOS 第三方库.插件.知名博客总结 用到的组件 1.通过CocoaPods安装 项目名称 项目信息 AFNetworking 网络请求组件 FMDB 本地数据库组件 SDWebImage 多个缩略图 ...

  8. 一些优秀的iOS第三方库

    文章目录 Kits ProgressHUD 加载与刷新 图像 引导页 Views Others Kits RegexKitRegexKit是一个正则表达式工具类. JSONKitJSONKit是一个比 ...

  9. iOS开发——UI篇&提示效果

    提示效果 关于iOS开发提示效果是一个很常见的技术,比如我们平时点击一个按钮,实现回馈,或者发送网络请求的时候! 技术点: 一:View UIAlertView UIActionSheet 二:控制器 ...

随机推荐

  1. psutil--跨平台的进程管理

    原文地址:http://www.jianshu.com/p/64e265f663f6 Python处理Windows进程 psutil(Python system and process utilit ...

  2. Hibernate从入门到精通(七)多对一单向关联映射

    上次的博文Hibernate从入门到精通(六)一对一双向关联映射中我们介绍了一下一对一双向关联映射,本次博文我们讲解一下多对一关联映射 多对一单向关联映射 多对一关联映射与一对一关联映射类似,只是在多 ...

  3. 【BZOJ 2440】[中山市选2011]完全平方数

    Description 小 X 自幼就很喜欢数.但奇怪的是,他十分讨厌完全平方数.他觉得这些数看起来很令人难受.由此,他也讨厌所有是完全平方数的正整数倍的数.然而这丝毫不影响他对其他数的热爱. 这天是 ...

  4. 0ffice365 Calendar API

    Calendar REST API in Office 365 APIs Preview http://msdn.microsoft.com/EN-US/library/office/dn792114 ...

  5. android项目在eclipse下编译运行的问题

    JDK与电脑系统要匹配,都是32位或者64位: android工程要与JDK相匹配,如果之前的android工程使用的jdk版本较高,则可能出现一些包或者类.方法.属性对应不上而报错,Android ...

  6. 1024: [SCOI2009]生日快乐 - BZOJ

    Description windy的生日到了,为了庆祝生日,他的朋友们帮他买了一个边长分别为 X 和 Y 的矩形蛋糕.现在包括windy,一共有 N 个人来分这块大蛋糕,要求每个人必须获得相同面积的蛋 ...

  7. EL表达式中如何截取字符串

    EL表达式中如何截取字符串 可以截取,用fn函数:<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/ ...

  8. c++ 字符串工具类

    #include <string> #include "util.h" namespace strtool{ std::string trim(const std::s ...

  9. 开扒本地存储—localStorage

    .localStorage是什么狂点查看demo localStorage用于持久化的本地存储,除非主动删除数据,否则数据是永远不会过期 的. 2.localStorage有哪些优点 1). 存储空间 ...

  10. GameAdmin

    username:root e-mail :123@qq.com password:123