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. [心得]传统IT转互联网面试经验分享

    http://www.newsmth.net/bbstcon.php?board=Java&gid=374779 传统IT外企干了8年,两年前转互联网的,面的和被面的都不少.这几天项目空档期, ...

  2. lufylegend库 LTextField

    lufylegend库 LTextField <!DOCTYPE html> <html lang="en"> <head> <meta ...

  3. (二)Hololens Unity 开发之 语音识别

    学习源于官方文档 Voice input in Unity 笔记一部分是直接翻译官方文档,部分各人理解不一致的和一些比较浅显的保留英文原文 (二)Hololens Unity 开发之 语音识别 Hol ...

  4. 【python基础】之list列表

    python提供了一个被称为列表的数据类型,他可以存储一个有序的元素集合. 记住:一个列表可以存储任意大小的数据集合.列表是可变对象,有别于字符串str类,str类是不可变对象. 1.创建一个列表 l ...

  5. JS与浏览器的几个兼容性问题

    第一个:有的浏览器不支持getElementsByClassName(),所以需要写一个function()来得到需要标签的class,然后进行class的增加.删除等操作. 第二个:在需要得到特定标 ...

  6. TypeScript教程3

    1.快速回顾一下这JavaScript中的命名函数和匿名函数: 纯文本查看 复制代码 1 2 3 4 5 //Named functionfunction add(x, y) {     return ...

  7. [CSS3]学习笔记-文字与字体相关样式

    1.给文字添加阴影 <!doctype html> <html> <head> <meta charset="utf-8"> < ...

  8. 有趣的++i和i++

    作为一个天天和代码“约会”的人来说i++和++i这玩意再熟悉不过了,因为使用频率太高了. 虽然如此,但也未必见得我们真的了解她,不妨猜猜下面的输出结果. #inlcude <stdio.h> ...

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

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

  10. localStorage 如何存储JSON数据并读取JSON数据

    localStorage是HTML5提供的再客户端实现本地存储的一种方法,但是localStorage方法只能存储字符串数据,有时候我们需要存储对象到本地比如:JSON:那么,localStorage ...