MBProgressHUD各种样式用法
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各种样式用法的更多相关文章
- 制作透明色:《CSS3 RGBA》与Opacity样式用法
前面我们一起探讨了一下CSS3 Gradient(css3 渐变),今天我们一起来探讨一下CSS3中的RGBA.RGB对于大家来说一点不陌生,他就是红色R+绿色G+蓝色B,那现在我们所说的RGBA又是 ...
- JS操作css样式用法
//html <div id="div1" style="background:red;"> 修改背景颜色 </div> <but ...
- class属性多个样式的用法
今天看到一个非常好用的样式用法,给已经在睡梦中苏醒的你们来一段代码头脑风暴.大家都知道现在div+css布局的使用已经不是可以用潮流来概括的了,换个词应该是:普及.以前的表格布局现在是少之极少,因为表 ...
- vue关于class和样式的使用
这篇文章主要为大家详细介绍了Vue.js的Class与样式绑定,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 数据绑定一个常见需求是操作元素的 class 列表和它的内联样式.因为它们都是 att ...
- 如何javascript获取css中的样式
obj.style.height只能获取行间样式,但是我们要怎么获取写在css文件中的样式呢? 首先我们要用一个新的方法currentStyle.这个方法由current和style两个单词组成意思是 ...
- CSS基础--常用样式
一.背景相关 背景颜色 background-color :颜色名称/rgb值/十六进制值 背景图片 background-image :url('') 背景图片平铺方式 background-rep ...
- JQuery的基本用法总结
1.jquery概念 是js的一个类库 (对js中某些功能的封装) 用jq实现的功能一定能用js实现 反过来 不一定 ,js实现的功能jq不一定能实现 2.jquery好处 1.代码简洁 2. ...
- 为什么我获取不到这个css样式?js原生获取css样式总结
还是自己遇到的一个坑的总结吧!与其说是坑不如说自己学艺不精,让我先哭一会!! 需求 简单就是获取一个css的height (好吧 就是一个这么简单的需求) 实践 好吧 长时间的JQ 我已经对原生无能了 ...
- UICollectionViewCell定制Button
UICollectionViewCell定制Button 效果 特点 1.能够动态设置每行显示的按钮的个数,以及控件的摆放格式 2.实现单选或者多选的功能,实现点击事件 3.自定制按钮的显示样式 用法 ...
随机推荐
- CodeForces 429B
Working out Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Desc ...
- 转:Oracle弃用sun.reflect.Reflection.getCallerClass
http://www.infoq.com/cn/news/2013/07/Oracle-Removes-getCallerClass 作为Java开发者,我们经常忽略@Deprecated注释,继续使 ...
- 《JAVASCRIPT高级程序设计》Ajax与Comet
Ajax,是Asynchronous JavaScript + XML的简写,这一技术能向服务器请求额外的技术而无需卸载页面,会带给用户更好的体验.Ajax的核心是XMLHttpRequest对象.为 ...
- 持久层框架之MyBatis
1.mybatis框架介绍: MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并 ...
- 源码(08) -- java.util.ListIterator<E>
java.util.ListIterator<E> 源码分析(JDK1.7) ------------------------------------------------------- ...
- C# 6 与 .NET Core 1.0 高级编程 - 37 章 ADO.NET
译文,个人原创,转载请注明出处,有不对的地方欢迎指出与交流. 英文原文:Professional C# 6 and .NET Core 1.0 - 37 ADO.NET --------------- ...
- arcpy.mapping实战-专题图制图自动化
arcpy.mapping实战-专题图制图自动化 by 李远祥 最初对arcpy.mapping感兴趣是因为一次大规模的专题地图调整的需要,由于某某单位利用ArcEngine编写的专题图出图系统,出现 ...
- js小功能合集:计算指定时间距今多久、评论树核心代码、字符串替换和去除。
1.计算指定时间距今多久 var date1=new Date('2017/02/08 17:00'); //开始时间 var date2=new Date(); //当前时间 var date3=d ...
- JS打开摄像头并截图上传
直入正题,JS打开摄像头并截图上传至后端的一个完整步骤 1. 打开摄像头主要用到getUserMedia方法,然后将获取到的媒体流置入video标签 2. 截取图片主要用到canvas绘图,使用dra ...
- C#属性和字段
属性 属性是一种用于访问对象或类的特性的成员.属性是字段的自然扩展,这两者都是具有关联类型的命名成员.而且访问字段和属性的语法是相同的.然而,与字段不同,属性不表示存储位置.相反属性具有访问器,这些访 ...