iOS -- MBProgressHUB
高级: http://www.jianshu.com/p/485b8d75ccd4
//只有小菊花
- (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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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.windowanimated: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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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 = [CABasicAnimationanimationWithKeyPath:@"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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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 = [MBProgressHUDshowHUDAddedTo: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];
});
});
}
#pragma mark - Tasks
- (void)doSomeWork {
// Simulate by just waiting.
sleep(3.);
}
iOS -- MBProgressHUB相关推荐
- IOS 分享 牛人 Demo
iphone开发十几个实用demo合集 2012(秋季)CocoaChina开发者大会专题回顾 公司接了个培训项目,给一个外包公司培训一批应届生,我从课程一半开始接手,讲了一个多月,内容包括UITab ...
- Xcode couldn‘t find any iOS App Development provisioning profiles matching ‘com.example.***‘
在更新完iOS14.3后,Xcode真机调试时报错,无法进行真机测试: 报以下错误: No profiles for 'com.example.software.Login' were found: ...
- iOS视频硬编码技术
iOS视频硬编码技术 一.iOS视频采集硬编码 基本原理 硬编码 & 软编码 硬编码:通过系统自带的Camera录制视频,实际上调用的是底层的高清编码硬件模块,即显卡,不使用CPU,速度快 软 ...
- iphone smtp服务器没有响应,电子邮件卡在iPhone或iPad上的发件箱?如何修复iOS中的未发送邮件 | MOS86...
您曾经在iOS中发送电子邮件,只能将信息卡在iPhone,iPad或iPod touch的邮件应用发件箱中?你知道这是什么时候发生的,因为在iOS的Mail应用程序的底部,状态栏在iOS中显示1个未发 ...
- layer弹窗在IOS上,被软键盘挤到上边的解决方法
就像这种情况,经过多番请教跟尝试,找到一个能解决这个问题的方法,但可能有点笨重.就是在当前弹框里,设置offset的值,里边的值可以随意写,然后再下边给弹框追加一个样式即可. <!DOCTYPE ...
- iOS开发8:使用Tool Bar切换视图
之前讨论的都是单视图应用程序,而在实际应用中,我们可能要多个视图,并根据用户的需要切换视图. iOS中几种典型的多视图程序: (1)Tab Bar Application:程序的底部有一排按钮,轻触其 ...
- 25个增强iOS应用程序性能的提示和技巧 — 中级篇
本文由破船译自:raywenderlich 转载请注明出处:BeyondVincent的博客 _____________ 在开发iOS应用程序时.让程序具有良好的性能是非常关键的.这也是用户所期望的. ...
- iOS Webview打开不受信的URL
在我们开发过程中经常会碰到直接访问开发人员的私有地址, 这样在app 上是无法打开指定的网页的. 在iOS中需要对WKWebView 进行如下设置: 1.在工程的Plist 文件中添加一下选项 App ...
- iOS蓝牙开发---CoreBluetooth[BLE 4.0] 初级篇[内附Demo地址]
一.蓝牙基础知识 (一)常见简称 1.MFI make for ipad ,iphone, itouch 专们为苹果设备制作的设备,开发使用ExternalAccessory 框架(认证流程貌似挺复 ...
- iOS 开发经验总结
iOS 开发经验总结http://www.cocoachina.com/ios/20170216/18699.html 1.cocoa pods 常用的framework 1 2 3 4 5 6 7 ...
最新文章
- “智能+”时代,看见别人看不见的才是赢家
- [蓝桥杯][2018年第九届真题]调手表(BFS)
- 1 week110的zookeeper的安装 + zookeeper提供少量数据的存储
- pycharm remote 远程项目 同步 本地_利器:PyCharm本地连接服务器搭建深度学习实验环境的三重境界...
- 说下Java堆空间结构,及常用的jvm内存分析命令和工具
- 10万码农五年的C语言笔记!你现在知道别人为什么这么优秀了吗?
- 截取含HTML标签的字符串
- 杨辉三角(二项式定理)组合数 【noip 2011/2016 d2t1】
- 执行shell脚本报/bin/bash^M: bad interpreter
- 【书籍阅读】-人在回路机器学习 Human-in-the-Loop Machine Learning(一)
- python艺术分形数_Python分形盒计数-分形维数
- 教你使用jmeter实现接口性能测试
- SPSS-相关分析(实例讲解)-数据分析
- 如何下载VMWare虚拟机如何安装VMWare详细教程
- flashplayer显示微软雅黑粗体bug
- python对Excel合并单元格拆分
- mysql的exception_mysqlexception
- 无线分组网关系统解决方案(GGSN、PDSN)
- 导出excel 并且处理长数字,处理科学计数法,以文本形式存储的数字
- 我做产品经理这半年来的经验总结(一)
热门文章
- 多线程三大概念:并发并行,阻塞,同异步
- Python—什么是duck type鸭子类型
- Python与C:指针与按址传递
- sklearn学习笔记之metrics
- 【论文阅读】Automated quantification of white matter lesion in magnetic resonance imaging
- linux查看谷歌服务,如何查询Linux服务的作用
- linux下下载fnl数据,NCEP再分析资料FNL数据在windows平台用cygwin批量下载方法
- 计算机如何建筑材料结合所学知识,《技术与设计2》第三、四单元检测试卷
- 搭建Hadoop集群
- bzoj 5120: [2017国家集训队测试]无限之环【最小费用最大流】