第三方框架MBProgressHUD-----实现各种提示框
程序运行显示如下 :
点击按钮实现对应的提示框:
这里只截取了其中一张图,有兴趣的可以自己运行程序,查看其他的几种提示框哟!!!
第三方框架MBProgressHUD的下载地址:https://github.com/jdg/MBProgressHUD
程序代码如下 :
//
// ViewController.m
// 第三方框架--提示框
//
// Created by mac1 on 15/10/5.
// Copyright (c) 2015年 www.iphonetrain.com. All rights reserved.
//
#import "ViewController.h"
#import "MBProgressHUD.h"
@interface ViewController ()
- (IBAction)textDialog:(id)sender;
- (IBAction)progressDialog1:(id)sender;
- (IBAction)progressDialog2:(id)sender;
- (IBAction)customDialog:(id)sender;
- (IBAction)allTextDialog:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
//文本提示框
- (IBAction)textDialog:(id)sender {
//创建进度框
__block MBProgressHUD *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 = nil; //block中改变对象值,__block
}];
}
//进度提示框一
- (IBAction)progressDialog1:(id)sender {
//创建进度框
__block MBProgressHUD *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.01;
hud.progress = progress;
usleep(50000);
}
} completionBlock:^{
//完成后执行的操作
[hud removeFromSuperview];
hud = nil;
}];
}
//进度提示框二
- (IBAction)progressDialog2:(id)sender {
//创建进度框
__block MBProgressHUD *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.01;
hud.progress = progress;
usleep(50000);
}
} completionBlock:^{
//完成后执行的操作
[hud removeFromSuperview];
hud = nil;
}];
}
//自定义进度框
- (IBAction)customDialog:(id)sender {
//创建进度框
__block MBProgressHUD *hud = [[MBProgressHUD alloc]initWithView:self.view];
[self.view addSubview:hud];
hud.labelText = @"操作成功";
hud.customView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"checkmark.png"]];
[hud showAnimated:YES whileExecutingBlock:^{
//休眠2秒
sleep(2);
} completionBlock:^{
[hud removeFromSuperview];
hud = nil;
}];
}
//纯文本提示框
- (IBAction)allTextDialog:(id)sender {
//创建进度框
__block MBProgressHUD *hud = [[MBProgressHUD alloc]initWithView:self.view];
[self.view addSubview:hud];
hud.labelText = @"你操作对了哟!!!";
hud.mode = MBProgressHUDModeText;
//指定显示文本的偏移量,不指定默认显示在屏幕中间
/*
hud.xOffset = 150;
hud.yOffset = 200;
*/
[hud showAnimated:YES whileExecutingBlock:^{
sleep(3);
} completionBlock:^{
[hud removeFromSuperview];
hud = nil;
}];
}
@end
第三方框架MBProgressHUD-----实现各种提示框的更多相关文章
- iOS 第三方框架-MBProgressHUD
MBProgressHUD提示框官网地址:https://github.com/jdg/MBProgressHUD 官网里已经提供了足够多的例子供我们使用,但在实现开发中,我们用到的只是其中的一小部分 ...
- ios学习--第三方框架-MBProgressHUD以及扩展
MBProgressHUD提示框官网地址:https://github.com/jdg/MBProgressHUD 一. 模式 首先, MBProgressHUD有以下几种视图模式. typedef ...
- js中提示框闪退问题
当页面存在刷新 或 在线引用iframe框架时(引用框架也会导致刷新) 会导致页面加载时的弹出框闪退 解决方法:设置弹出框在页面或者框架完全加载一段时间后再弹出 <script type=& ...
- 【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果
原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单.方便,并且可以对显 ...
- 【转】IOS学习笔记29—提示框第三方库之MBProgressHUD
原文网址:http://blog.csdn.net/ryantang03/article/details/7877120 MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单 ...
- iOS提示框,为什么你应该使用 MBProgressHUD?
这是一篇带有一定笔者主观感情色彩的比较文章.文章着重对比github上最流行的两个iOS进度提示控件 MBProgressHUD 与 SVProgressHUD的各自优劣,来帮助初学者找到一个适合的i ...
- Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog)
Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog) Android第三方开源对话消息提示框:SweetAlertDialog(sweet- ...
- 提示框框架KVNProgress介绍
gitHub上面有很多显示加载进度的框架,这里我们介绍一下KVNProgress框架,KVNProgress是一个可以完全定制的HUD(指示器),你可以设置加载进度的画面是否全屏,可以自己修改进度显示 ...
- 【开源类库学习】MBProgressHUD(提示框)
新博客: http://www.liuchendi.com MBProgressHUD是一个开源类库,实现了各种样式的提示框, 下载地址:https://github.com/jdg/MBProgre ...
随机推荐
- Robot Framework--连接Mysql数据库
1.安装Database-Library 输入命令:pip install robotframework_databaselibrary 2.添加Database的Library 3.实例 *** T ...
- centos安装nodejs和配置npm
1.下载安装nodejs 1 wget http://nodejs.org/dist/v7.4.0/node-v7.4.0.tar.gz 2 yum install gcc openssl-devel ...
- Linux中drwxr-xr-x.的意思和权限
转载:https://blog.csdn.net/weixin_39209728/article/details/79729885 读(read),写(write),执行r(recute)简写即为(r ...
- [English] - 单词阶段1
百词斩这个app很好玩,尤其是在记忆单词的时候,效果显著. 有的PK赛场也是比较谁的单词翻译提交的快,这个我曾经连胜好几次.
- CSP 2019 退役记
声明:博主不会时空穿越,也没有造成恐慌,不应禁赛三年 Day0 上午:打板子 Polya定理; exkmp; exbsgs; 乘法逆元; 矩阵快速幂; 扫描线; ST表; excrt; Dirichl ...
- 【02NOIP提高组】均分纸牌
#include<bits/stdc++.h> using namespace std; ; int n,sum,a[maxn]; int main() { ; cin>>n; ...
- 【00NOIP提高组】单词接龙
#include<bits/stdc++.h> using namespace std; ; int n,length; int vis[N]; string str[N]; inline ...
- 10-5使用OpenType字体
http://www.missyuan.com/viewthread.php?tid=350835&extra=&page=1 现在当我们通过Photoshop.Word或其他应用程序 ...
- shell 脚本同时对远程多台机器执行命令
脚本1:需要机器之间免密 ssh-copy-id [-i [identity_file]] [user@]machine #!/bin/bash # ------------------------- ...
- Tkinter 之MessageBox弹出框
一.参数说明 语法 作用 截图 tk.messagebox.showwarning(title='提示', message='你确定要删除吗?') 警告信息弹窗 tk.messagebox.sho ...