IOS 公共类-MyMBProgressUtil Progress显示

此公共类用于显示提示框,对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-, hud.frame.size.height-);
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 公共类-MyMBProgressUtil Progress显示的更多相关文章

  1. IOS 公共类-MyDateUtil 日期处理Util

    IOS 公共类-MyDateUtil 日期处理Util 此为处理日期的公共类.适用IOS6+ .h文件: #import <Foundation/Foundation.h> //适用 IO ...

  2. IOS 公共类-数字处理

    1.写一个方法,调用的时候交换两个数的值 -(void) swap:(int*)a andNumber:(int*)b{ int temp = *a; *a = *b; *b = temp; } 调用 ...

  3. Mybatis包分页查询java公共类

    Mybatis包分页查询java公共类   分页----对于数据量非常大的查询中.是不可缺少的. mybatis底层的分页sql语句因为须要我们自己去手动写.而实现分页显示的时候我们须要依据分页查询条 ...

  4. iOS开发-类簇(Class Cluster)

    类簇(Class  Cluster)是定义相同的接口并提供相同功能的一组类的集合,仅公开接口的抽象类也可以称之为类簇的公共类,每个具体类的接口有公共类的接口抽象化,并隐藏在簇的内部.这些类一般不能够直 ...

  5. 一个Java文件至多包含一个公共类

    编写一个java源文件时,该源文件又称为编译单元.一个java文件可以包含多个类,但至多包含一个公共类,作为编译时该java文件的公用接口,公共类的名字和源文件的名字要相同,源文件名字的格式为[公共类 ...

  6. ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl

    ASP.NET中常用的几个开源公共类: LTP.Common.dll: 通用函数类库     源码下载Maticsoft.DBUtility.dll 数据访问类库组件     源码下载LtpPageC ...

  7. Java ClassLoader基础及加载不同依赖 Jar 中的公共类

    转载自:最新内容及最清晰格式请见 http://www.trinea.cn/android/java-loader-common-class/ 本文主要介绍 ClassLoader 的基础知识,Cla ...

  8. ASP.NET中常用的几个李天平开源公共类LTP.Common,Maticsoft.DBUtility,LtpPageControl (转)

    ASP.NET中常用的几个开源公共类: LTP.Common.dll: 通用函数类库     源码下载Maticsoft.DBUtility.dll 数据访问类库组件     源码下载LtpPageC ...

  9. 一位iOS教育类应用开发者是如何赚到60多万美元?

    注:伯乐在线12月19日在@程序员的那些事 微博推荐了此文的英文原文,非常感谢@dotSlash 的翻译.  转眼距我写<我如何在iOS教育类应用中赚到20万美元>这篇博文已经一年多了,它 ...

随机推荐

  1. java安装教程

    1.安装中,jdk和jre的安装在不同的目录中 2.环境变量的配置 选择系统变量中 新建以下3个环境变量: JAVA_HOME  jdk安装路径 CLASSPATH  .;%JAVA_HOME%\li ...

  2. app.js

    //第一步,引入express模块 var exp = require('express'),     http = require('http'),//引入http模块     path = req ...

  3. Cracking-- 4.7 在一颗二叉树中找两个节点的第一个共同祖先

    分别记录从 root 到 node1 的path 到 node2的path,再找其中共同的部分 struct Node{ int val; struct Node *left; struct Node ...

  4. STM32 GPIO外部中断总结

    一.STM32中断分组: STM32 的每一个GPIO都能配置成一个外部中断触发源,这点也是 STM32 的强大之处.STM32 通过根据引脚的序号不同将众多中断触发源分成不同的组,比如:PA0,PB ...

  5. 批量创建SQL Server分区文件

    ) declare @i int set @table = 'v3_yqsd_report' begin exec('alter database '+@table+' add filegroup O ...

  6. ngixn编译安装时,pcre的处理

    nginx编译时pcre会提示找不到libpcre.so.1 ./configure --hlep --without-pcre disable PCRE library usage   不使用pcr ...

  7. INotifyPropertyChanged接口的PropertyChanged 事件

    INotifyPropertyChanged 接口用于向客户端(通常是执行绑定的客户端)发出某一属性值已更改的通知. 例如,考虑一个带有名为 FirstName 属性的 Person 对象. 若要提供 ...

  8. 设置代码Code高亮显示成蓝色

    下面方法是让设置的关键字高亮显示,考虑到了注释与字符串的影响,所以备用,以便将来能够用到. private static void ColorizeCode(RichTextBox rtb) { st ...

  9. bochs上网及配置

    下载并安装bochs2.6:(不能是更高版本) 创建bochs 时注意勾选Dlx linux Demo,但是其文件bochsrc.bxrc中无Ne2k网卡选项,这一段要自己添加,详情见后. 先确定我们 ...

  10. TCL:读取表格(xls)中的数据

    intToChar.tcl # input a number : 1 to 32 , you will get a char A to Z #A-Z:1-32 proc intToChar {int} ...