demo 来源: https://github.com/jdg/MBProgressHUD/

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px "PingFang SC"; color: #1d9421 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421 }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3c828c }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px }
p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3d1d81 }
p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c91b13 }
p.p8 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #31595d }
p.p9 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #294c50 }
p.p10 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #822e0e }
p.p11 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #6122ae }
p.p12 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #703daa }
p.p13 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #539aa4 }
span.s1 { font: 18.0px Menlo }
span.s2 { }
span.s3 { color: #c32275 }
span.s4 { color: #000000 }
span.s5 { color: #294c50 }
span.s6 { color: #703daa }
span.s7 { color: #0435ff }
span.s8 { color: #539aa4 }
span.s9 { color: #78492a }
span.s10 { font: 18.0px "PingFang SC" }
span.s11 { color: #6122ae }
span.s12 { color: #c91b13 }
span.s13 { color: #3d1d81 }
span.s14 { font: 18.0px "PingFang SC"; color: #c91b13 }
span.s15 { color: #1d9421 }
span.s16 { font: 18.0px "PingFang SC"; color: #1d9421 }
span.Apple-tab-span { white-space: pre }

//只有小菊花

- (void)indeterminateExample {

// Show the HUD on the root view (self.view is a scrollable table view and thus not suitable,

// as the HUD would move with the content as we scroll).

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Fire off an asynchronous task, giving UIKit the opportunity to redraw wit the HUD added to the

// view hierarchy.

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background

[self doSomeWork];

// IMPORTANT - Dispatch back to the main thread. Always access UI

// classes (including MBProgressHUD) on the main thread.

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//小菊花+文字

- (void)labelExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the label text.

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

// You can also adjust other label properties if needed.

// hud.label.font = [UIFont italicSystemFontOfSize:16.f];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//小菊花+文字+detailsLabel

- (void)detailsLabelExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the label text.

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

// Set the details label text. Let's make it multiline this time.

hud.detailsLabel.text = NSLocalizedString(@"Parsing data\n(1/1)", @"HUD title");

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

- (void)windowExample {

// Covers the entire screen. Similar to using the root view controller view.

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//圆环进度条+文字

- (void)determinateExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminate;

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//圆环进度条+文字+ 取消按钮

- (void)determinateNSProgressExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminate;

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

// Set up NSProgress

NSProgress *progressObject = [NSProgress progressWithTotalUnitCount:100];

hud.progressObject = progressObject;

// Configure a cancel button.

[hud.button setTitle:NSLocalizedString(@"Cancel", @"HUD cancel button title") forState:UIControlStateNormal];

[hud.button addTarget:progressObject action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgressObject:progressObject];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//圆环进度条+文字

- (void)annularDeterminateExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the annular determinate mode to show task progress.

hud.mode = MBProgressHUDModeAnnularDeterminate;

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//直线进度条+文字

- (void)barDeterminateExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the bar determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminateHorizontalBar;

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

#pragma mark --自定义视图

//自定义视图

- (void)customViewExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the custom view mode to show any view.

hud.mode = MBProgressHUDModeCustomView;

// Set an image view with a checkmark.

//default

//    UIImage *image = [[UIImage imageNamed:@"Checkmark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

//mxs

//UIImage *image = [[UIImage imageNamed:@"下拉刷新一80x80"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];//success  下拉刷新一80x80 密码登录lgo

UIImage *image = [UIImage imageNamed:@"下拉刷新一80x80"];//success  下拉刷新一80x80 密码登录lgo

UIImageView *imgV = [[UIImageView alloc] initWithImage:image];

[imgV.layer addAnimation:[self makeRotation] forKey:nil];

hud.customView = imgV;

// Looks a bit nicer if we make it square.

hud.square = YES;

// Optional label text.

hud.label.text = @"Done";

[hud hideAnimated:YES afterDelay:2.f];//几秒后消失

}

#pragma mark --旋转

- (CABasicAnimation *)makeRotation{

CATransform3D rotationTransform = CATransform3DMakeRotation((360*180.0)/(M_PI), 0, 0, -1);

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];

animation.toValue = [NSValue valueWithCATransform3D:rotationTransform];

animation.duration  =  1;

animation.autoreverses = NO;

animation.cumulative = YES;

animation.fillMode = kCAFillModeForwards;

animation.repeatCount = 100;

return animation;

}

//只有文字

- (void)textExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the text mode to show only text.

hud.mode = MBProgressHUDModeText;

hud.label.text = NSLocalizedString(@"Message here!", @"HUD message title");

// Move to bottm center.

hud.offset = CGPointMake(0.f, MBProgressMaxOffset);

[hud hideAnimated:YES afterDelay:3.f];

}

- (void)cancelationExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminate;

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

// Configure the button.

[hud.button setTitle:NSLocalizedString(@"Cancel", @"HUD cancel button title") forState:UIControlStateNormal];

[hud.button addTarget:self action:@selector(cancelWork:) forControlEvents:UIControlEventTouchUpInside];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//小菊花--转换-->圆环

- (void)modeSwitchingExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set some text to show the initial status.

hud.label.text = NSLocalizedString(@"Preparing...", @"HUD preparing title");

// Will look best, if we set a minimum size.

hud.minSize = CGSizeMake(150.f, 100.f);

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithMixedProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

- (void)networkingExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set some text to show the initial status.

hud.label.text = NSLocalizedString(@"Preparing...", @"HUD preparing title");

// Will look best, if we set a minimum size.

hud.minSize = CGSizeMake(150.f, 100.f);

[self doSomeNetworkWorkWithProgress];

}

- (void)dimBackgroundExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Change the background view style and color.

hud.backgroundView.style = MBProgressHUDBackgroundStyleSolidColor;

hud.backgroundView.color = [UIColor colorWithWhite:0.f alpha:0.1f];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

- (void)colorExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

hud.contentColor = [UIColor colorWithRed:0.f green:0.6f blue:0.7f alpha:1.f];

// Set the label text.

hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title");

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #822e0e }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421 }
span.s1 { }
span.s2 { color: #c32275 }
span.s3 { color: #000000 }
span.s4 { color: #3d1d81 }
span.s5 { color: #0435ff }

#pragma mark - Tasks

- (void)doSomeWork {

// Simulate by just waiting.

sleep(3.);

}

MBProgressHUD各种样式用法的更多相关文章

  1. 制作透明色:《CSS3 RGBA》与Opacity样式用法

    前面我们一起探讨了一下CSS3 Gradient(css3 渐变),今天我们一起来探讨一下CSS3中的RGBA.RGB对于大家来说一点不陌生,他就是红色R+绿色G+蓝色B,那现在我们所说的RGBA又是 ...

  2. JS操作css样式用法

    //html <div id="div1" style="background:red;"> 修改背景颜色 </div> <but ...

  3. class属性多个样式的用法

    今天看到一个非常好用的样式用法,给已经在睡梦中苏醒的你们来一段代码头脑风暴.大家都知道现在div+css布局的使用已经不是可以用潮流来概括的了,换个词应该是:普及.以前的表格布局现在是少之极少,因为表 ...

  4. vue关于class和样式的使用

    这篇文章主要为大家详细介绍了Vue.js的Class与样式绑定,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 数据绑定一个常见需求是操作元素的 class 列表和它的内联样式.因为它们都是 att ...

  5. 如何javascript获取css中的样式

    obj.style.height只能获取行间样式,但是我们要怎么获取写在css文件中的样式呢? 首先我们要用一个新的方法currentStyle.这个方法由current和style两个单词组成意思是 ...

  6. CSS基础--常用样式

    一.背景相关 背景颜色 background-color :颜色名称/rgb值/十六进制值 背景图片 background-image :url('') 背景图片平铺方式 background-rep ...

  7. JQuery的基本用法总结

    1.jquery概念 是js的一个类库    (对js中某些功能的封装) 用jq实现的功能一定能用js实现 反过来 不一定  ,js实现的功能jq不一定能实现 2.jquery好处 1.代码简洁 2. ...

  8. 为什么我获取不到这个css样式?js原生获取css样式总结

    还是自己遇到的一个坑的总结吧!与其说是坑不如说自己学艺不精,让我先哭一会!! 需求 简单就是获取一个css的height (好吧 就是一个这么简单的需求) 实践 好吧 长时间的JQ 我已经对原生无能了 ...

  9. UICollectionViewCell定制Button

    UICollectionViewCell定制Button 效果 特点 1.能够动态设置每行显示的按钮的个数,以及控件的摆放格式 2.实现单选或者多选的功能,实现点击事件 3.自定制按钮的显示样式 用法 ...

随机推荐

  1. 一步一步学Java IO

    1.基本概念 1.1.InputStream 最基本的字节输入流,抽象类,定义了读取原始字节的所有基本方法1.1.1.public abstract int read() throws IOExcep ...

  2. 基于Ubuntu 14.04构建mysql5.6 Docker镜像

    我们的目的是创建一个基于Ubuntu 14.04 的MySQL的 Docker Image,并且在新创建出来的容器里自动启动MySQL服务接受外部连接 步骤: 1. 首先创建一个目录并在目录下创建一个 ...

  3. Web前端常用快捷键总结(OS X系统)

    OS X系统截图:command + shift + 4 强制关闭OS X系统内无响应的程序:command + option +ESC Sublime Text 3: 显示或隐藏Side Bar:c ...

  4. 初识Dapper

    16年年底开发一个项目,拍卖的项目,对于我这个不入流的程序员来说,雪微是个挑战.程序猿这个行业就是学到老用到老吧.个人比较喜欢sql原生的写法,对EF 还是不怎么感冒,EF 虽然强大,但是用起来还不怎 ...

  5. 【长 PI】

    /* 长 PI 说明: 圆周率后的小数位数是无止境的,如何使用电脑来计算这无止境的小数是一些数学家与程式设计师所感兴趣的,在这边介绍一个公式配合 大 数运算,可以计算指定位数的圆周率. 解法 : 首先 ...

  6. MyBatis:学习笔记(3)——关联查询

    MyBatis:学习笔记(3)--关联查询 关联查询 理解联结 SQL最强大的功能之一在于我们可以在数据查询的执行中可以使用联结,来将多个表中的数据作为整体进行筛选. 模拟一个简单的在线商品购物系统, ...

  7. Xamarin 小试牛刀 通知栏消息通知和按钮(基于Java代码人肉转换)

    本示例基于网友现有安卓项目人肉翻译,在Xamarin中替换和修改了很多方法的命名,比如某些属性需要去掉getName的get前缀, 有些方法名称需要使用Pascal命名法替换Java的Camel 命名 ...

  8. 微信前端面试题----js实现LazyMan

    这是微信小程序的一道面试题,题目是这样的: 实现一个LazyMan,可以按照以下方式调用:LazyMan("Hank")输出:Hi! This is Hank! LazyMan(& ...

  9. mysql学习之权限管理

    数据库权限的意义: 为了保证数据库中的业务数据不被非授权的用户非法窃取,需要对数据库的访问者进行各种限制,而数据库安全性控制措施主要有这三种,第一种用户身份鉴别,手段可以是口令,磁卡,指纹等技术,只有 ...

  10. 移动HTML5前端性能优化总结

    概述 1. PC优化手段在Mobile侧同样适用 2. 在Mobile侧我们提出三秒种渲染完成首屏指标 3. 基于第二点,首屏加载3秒完成或使用Loading 4. 基于联通3G网络平均338KB/s ...