IOS 公共类-MyMBProgressUtil Progress显示
2016-03-19 21:40
615 查看
[b]IOS 公共类-MyMBProgressUtil Progress显示[/b]
此公共类用于显示提示框,对MBProgress的进一步封装。可以看下面的代码
接口:
实现类:
可以下载通过github:https://github.com/cjt321/MyMBProgressUtil
此公共类用于显示提示框,对MBProgress的进一步封装。可以看下面的代码
接口:
@interface MyMBProgressUtil //显示Progress在view上 +(void) showMBProgressHUDViewInView:(UIView*)view andText:(NSString*)text; //隐藏Progress在view上 +(void) hiddenMBProgressHUDViewInView:(UIView *)view; //显示Progress在window上 +(void) showMBProgressHUDViewInWindow; //隐藏Progress在window上 +(void) hiddenMBProgressHUDViewInWindow; //显示文字在view上,默认0.8秒后隐藏 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text; //显示文字在view上,自己设定多少秒后隐藏 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text withTimeSeconds:(CGFloat)seconds; //显示详细文字在view上,自己设定多少秒后隐藏 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withDetailText:(NSString*)detailText withTimeSeconds:(CGFloat)seconds; @end
实现类:
@implementation MyMBProgressUtil: NSObject +(void) showMBProgressHUDViewInView:(UIView*)view andText:(NSString*)text { MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; hud.clipsToBounds = NO; [hud setLabelText:text]; hud.removeFromSuperViewOnHide = YES; hud.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.3f]; CGRect frame = CGRectMake(hud.frame.origin.x, hud.frame.origin.y, hud.frame.size.width-20, hud.frame.size.height-20); hud.frame = frame; } +(void)hiddenMBProgressHUDViewInView:(UIView *)view { [MBProgressHUD hideHUDForView:view animated:YES]; } +(void) showMBProgressHUDViewInWindow { UIWindow *win = [UIApplication sharedApplication].keyWindow; MBProgressHUD *hud = [[MBProgressHUD alloc] initWithWindow:win]; hud.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.3f]; hud.mode = MBProgressHUDModeIndeterminate; hud.removeFromSuperViewOnHide = YES; [win addSubview:hud]; [hud show:YES]; } +(void) hiddenMBProgressHUDViewInWindow { UIWindow *win = [UIApplication sharedApplication].keyWindow; [MBProgressHUD hideHUDForView:win animated:YES]; } +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text{ MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; hud.mode = MBProgressHUDModeText; hud.labelText = text; hud.removeFromSuperViewOnHide = YES; [hud hide:YES afterDelay:0.8f]; } +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text withTimeSeconds:(CGFloat)seconds { MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; hud.mode = MBProgressHUDModeText; hud.labelText = text; hud.removeFromSuperViewOnHide = YES; [hud hide:YES afterDelay:seconds]; } +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withDetailText:(NSString*)detailText withTimeSeconds:(CGFloat)seconds { MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; hud.mode = MBProgressHUDModeText; hud.detailsLabelText = detailText; hud.removeFromSuperViewOnHide = YES; [hud hide:YES afterDelay:seconds]; } @end
可以下载通过github:https://github.com/cjt321/MyMBProgressUtil
相关文章推荐
- IOS 使用XIB 自定义View
- iOS Socket理论知识
- iOS 应用内的系统复制粘贴菜单显示的语言非中文
- 【iOS】ARM & MRC
- iOS如何给约束加动画?
- iOS之07-三大特性之多态 + NSString类
- 编写一个iOS应用之前必须做的7件事(附相关资源)
- iOS开发扫盲篇
- iOS 开发学习
- ios测试简介
- iOS-----用LLDB调试,让移动开发更简单(二)
- iOS---用LLDB调试,让移动开发更简单(一)
- GCD
- iOS TableView顶部上方留白的问题
- iOS TableView 滚动到最后一行
- iOS显示3D模型,iOS和U3D混编(互相跳转)
- iOS真机测试错误总结
- iOS开发-关于自定义控件很值得一看的文章( 四)
- 52.iOS9 适配教程
- 51.iOS9 新特性及适配