博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS 公共类-MyMBProgressUtil Progress显示
阅读量:7154 次
发布时间:2019-06-29

本文共 3316 字,大约阅读时间需要 11 分钟。

IOS 公共类-MyMBProgressUtil Progress显示

 

此公共类用于显示提示框,对MBProgress的进一步封装。可以看下面的代码

接口:

1 @interface MyMBProgressUtil  2  3 //显示Progress在view上 4 +(void) showMBProgressHUDViewInView:(UIView*)view andText:(NSString*)text; 5 //隐藏Progress在view上 6 +(void) hiddenMBProgressHUDViewInView:(UIView *)view; 7  8 //显示Progress在window上 9 +(void) showMBProgressHUDViewInWindow;10 //隐藏Progress在window上11 +(void) hiddenMBProgressHUDViewInWindow;12 13 //显示文字在view上,默认0.8秒后隐藏14 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text;15 //显示文字在view上,自己设定多少秒后隐藏16 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text withTimeSeconds:(CGFloat)seconds;17 //显示详细文字在view上,自己设定多少秒后隐藏18 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withDetailText:(NSString*)detailText withTimeSeconds:(CGFloat)seconds;19 20 @end

 

实现类:

1 @implementation MyMBProgressUtil: NSObject 2  3 +(void) showMBProgressHUDViewInView:(UIView*)view andText:(NSString*)text { 4     MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; 5     hud.clipsToBounds = NO; 6     [hud setLabelText:text]; 7     hud.removeFromSuperViewOnHide = YES; 8     hud.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.3f]; 9     CGRect frame = CGRectMake(hud.frame.origin.x, hud.frame.origin.y, hud.frame.size.width-20, hud.frame.size.height-20);10     hud.frame = frame;11 }12 13 +(void)hiddenMBProgressHUDViewInView:(UIView *)view {14     [MBProgressHUD hideHUDForView:view animated:YES];15 }16 17 +(void) showMBProgressHUDViewInWindow {18     UIWindow *win = [UIApplication sharedApplication].keyWindow;19     MBProgressHUD *hud = [[MBProgressHUD alloc] initWithWindow:win];20     hud.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.3f];21     hud.mode = MBProgressHUDModeIndeterminate;22     hud.removeFromSuperViewOnHide = YES;23     [win addSubview:hud];24     [hud show:YES];25 }26 27 28 +(void) hiddenMBProgressHUDViewInWindow {29     UIWindow *win = [UIApplication sharedApplication].keyWindow;30     [MBProgressHUD hideHUDForView:win animated:YES];31 }32 33 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text{34     MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];35     hud.mode = MBProgressHUDModeText;36     hud.labelText = text;37     hud.removeFromSuperViewOnHide = YES;38     [hud hide:YES afterDelay:0.8f];39 }40 41 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withText:(NSString*)text withTimeSeconds:(CGFloat)seconds {42     MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];43     hud.mode = MBProgressHUDModeText;44     hud.labelText = text;45     hud.removeFromSuperViewOnHide = YES;46     [hud hide:YES afterDelay:seconds];47 }48 49 +(void) showTextOnlyWithMBProgressHUDViewIn:(UIView*)view withDetailText:(NSString*)detailText withTimeSeconds:(CGFloat)seconds {50     MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];51     hud.mode = MBProgressHUDModeText;52     hud.detailsLabelText = detailText;53     hud.removeFromSuperViewOnHide = YES;54     [hud hide:YES afterDelay:seconds];55 }56 57 @end

 

可以下载通过github:https://github.com/cjt321/MyMBProgressUtil

 

posted on
2016-03-19 21:40 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/alunchen/p/5296422.html

你可能感兴趣的文章
[EmguCV|WinForm] 使用EmguCV內建直方圖工具繪製直方圖(Histogram)-直方圖(Histogram)系列 (1)...
查看>>
openjudge1768 最大子矩阵[二维前缀和or递推|DP]
查看>>
JSP学习初体验
查看>>
Linux 下一个很棒的命令行工具
查看>>
oracle 索引的(创建、简介、技巧、怎样查看)
查看>>
H5视频播放器属性与API控件,以及对程序的解释
查看>>
C++类的大小(转)
查看>>
Node+Express的跨域访问控制问题:Access-Control-Allow-Origin
查看>>
-03-PetaLinux通过eMMC方式启动【Xilinx-Petalinux学习】
查看>>
Scala进阶之路-Scala特征类与unapply反向抽取
查看>>
Portable way to get file size (in bytes) in shell?
查看>>
C++空类中的默认函数
查看>>
浅谈程序猿的职业规划,看你如何决定自己的未来吧。
查看>>
IOS debug网络PonyDebugger 实践篇
查看>>
Android 如何预置APK M
查看>>
《JAVA与模式》之命令模式
查看>>
U盘FAT32转换NTFS格式
查看>>
【iCore3双核心板】发布 iCore3 应用开发平台硬件原理图
查看>>
PhysX学习笔记(4): 动力学(3) Joint
查看>>
C#中海量数据的批量插入和更新
查看>>