iOS_第3方类库MBprogressHUD
2015-04-01 15:43
141 查看
时间 2014-08-06 18:22:29 CSDN博客原文 http://blog.csdn.net/pre_eminent/article/details/38405007
1,将下载好的第3方类库MBprogressHUD源码包 加入到工程 (其实就是一个.h和.m文件)
2,进入工程的Build Phases,将源码包里面的所有.m文件全部添加到工程
3,添加第3方类库的主头文件" MBProgressHUD.h"
显示代码:
隐藏代码:
自定义显示图片:
其他常用属性
1,将下载好的第3方类库MBprogressHUD源码包 加入到工程 (其实就是一个.h和.m文件)
2,进入工程的Build Phases,将源码包里面的所有.m文件全部添加到工程
3,添加第3方类库的主头文件" MBProgressHUD.h"
显示代码:
// 一开始加载就,显示提示条 MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:webView animated:YES]; // 加一层蒙版 hud.dimBackground = YES; hud.labelText = @"页面加载中...";
隐藏代码:
// 一旦加载完毕,就隐藏提示条 [MBProgressHUD hideAllHUDsForView:webView animated:YES];
自定义显示图片:
// 抽取的,仅供分类内部调用 + (void) showMsg:(NSString *)msg imgName:(NSString *)imgName { // 显示到主窗口中 MBProgressHUD *hud =[MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES]; // 显示模式,改成customView,即显示自定义图片(mode设置,必须写在customView赋值之前) hud.mode = MBProgressHUDModeCustomView; int delay = 1; if ([imgName isEqualToString:@"error.png"]) { // 错误时,提示3秒钟 delay = 3; } imgName = [NSString stringWithFormat:@"MBProgressHUD.bundle/%@",imgName]; // 设置要显示 的自定义的图片 hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imgName]]; // 显示的文字,比如:加载失败...加载中... hud.labelText = msg; // 标志:必须为YES,才可以隐藏, 隐藏的时候从父控件中移除 hud.removeFromSuperViewOnHide = YES; // 3秒后自动隐藏 log(@"%d",delay); [hud hide:YES afterDelay:delay]; }
其他常用属性
// 提示框的背景色 hud.color = [UIColor clearColor];//这儿表示无背景 // 提示下文的小文字 hud.detailsLabelText = @"detail"; // 阴影遮罩效果 hud.dimBackground = YES; // 1秒之后隐藏 [hud hide:YES afterDelay:1]; //只显示文字 hud.mode = MBProgressHUDModeText; // 外边距 和 Y方向偏移 hud.margin = 0; hud.yOffset = 0; // 隐藏后从父控件中移除 hud.removeFromSuperViewOnHide = YES; //圆形进度条 hud.mode = MBProgressHUDModeAnnularDeterminate;
相关文章推荐
- iOS_第3方类库MBprogressHUD
- IOS上的几个类库:MBProgressHUD、ASIHttpRequest、JSON Framework和Flurry
- IOS上的几个类库:MBProgressHUD、ASIHttpRequest、JSON Framework和Flurry
- iOS_第3方类库SDWebImage简单使用
- iOS_第3方类库SDWebImage
- iOS_第3方类库_側滑选项卡SlideSwitchView
- IOS上的几个类库:MBProgressHUD、ASIHttpRequest、JSON Framework和Flurry
- iOS_第3方类库_BlurAlertView_GPUImage
- IOS上的几个类库:MBProgressHUD、ASIHttpRequest、JSON Framework和Flurry
- iOS_第3方类库_侧滑选项卡SlideSwitchView
- iOS_第3方类库_BlurAlertView_GPUImage
- iOS_第3方类库_EGOImageView异步加载网络图片
- [ios2]10大iOS开发者最喜爱的类库
- iOS开发---开源项目和开源类库篇(持续更新中)
- IOS开发UI篇之──自定义加载等待框(MBProgressHUD)
- 开源中国iOS客户端学习——(五)网络通信ASI类库(1)
- 对比iOS网络类库:AFNetworking VS ASIHTTPRequest
- 一些iOS高效开源类库
- IOS MBProgressHUD 无法显示的问题
- iOS开发常用的第三方类库