MBProgressHUD是一個(gè)非常受歡迎的第三方庫(kù)酌壕,接口靈活掏愁、可擴(kuò)展性強(qiáng)、代碼樸實(shí)易懂卵牍、使用也相對(duì)簡(jiǎn)單果港。
為了可以在項(xiàng)目中更愉快的使用,對(duì)其進(jìn)行了常用功能的簡(jiǎn)單封裝糊昙。類(lèi)方法調(diào)用在使用中也更方便辛掠。
下面看看接口
/**
設(shè)置 MBProgressHUDBackgroundStyle 為 Blur
*/
+ (void)setHUDBackgroundStyleBlur;
/**
設(shè)置 MBBackgroundView 的 color
@param color UIColor
*/
+ (void)setHUDBackgroundViewColor:(UIColor *)color;
/**
設(shè)置 BezelView 的顏色
@param color UIColor
*/
+ (void)setHUDBezelViewColor:(UIColor *)color;
/**
設(shè)置顯示內(nèi)容的顏色
@param color UIColor
*/
+ (void)setHUDContentColor:(UIColor *)color;
/**
設(shè)置 HUD 內(nèi)容邊距
@param margin margin
*/
+ (void)setHUDMargin:(CGFloat)margin;
/**
設(shè)置 HUD 最小尺寸
@param minSize minSize
*/
+ (void)setHUDMInSize:(CGSize)minSize;
/**
讓SuperView響應(yīng)操作,即禁用HUD的 userInteractionEnabled = NO
*/
+ (void)superViewUserInteractionEnabled;
/**
顯示文字释牺,自動(dòng)消失
@param title title
@param view superView
*/
+ (void)showTitle:(NSString *)title onView:(UIView *)view;
/**
顯示設(shè)置好的成功圖片萝衩,自動(dòng)消失
@param title title
@param view superView
*/
+ (void)showSuccess:(NSString *)title onView:(UIView *)view;
/**
顯示設(shè)置好的錯(cuò)誤圖片,自動(dòng)消失
@param title title
@param view superView
*/
+ (void)showError:(NSString *)title onView:(UIView *)view;
/**
顯示設(shè)置好的警示圖片没咙,自動(dòng)消失
@param title title
@param view superView
*/
+ (void)showWarning:(NSString *)title onView:(UIView *)view;
/**
顯示設(shè)置好的自定義的圖片猩谊,自動(dòng)消失
@param img img
@param title title
@param view superView
*/
+ (void)showCustomImage:(UIImage *)img title:(NSString *)title onView:(UIView *)view;
/**
顯示 UIActivityIndicatorView StyleWhiteLarge 的等待動(dòng)畫(huà),需手動(dòng)消失
@param title title
@param view superView
*/
+ (void)showLoading:(NSString *)title onView:(UIView *)view;
/**
顯示 UIActivityIndicatorView StyleWhite 的等待動(dòng)畫(huà)祭刚,需手動(dòng)消失
@param title title
@param view superView
*/
+ (void)showLoadingSmall:(NSString *)title onView:(UIView *)view;
/**
顯示 預(yù)設(shè)的圓形等待動(dòng)畫(huà)牌捷,需手動(dòng)消失
@param title title
@param view superView
*/
+ (void)showLoadingCircle:(NSString *)title onView:(UIView *)view;
/**
顯示 自定義的 幀動(dòng)畫(huà),需手動(dòng)消失
@param imagArray 動(dòng)畫(huà)圖片數(shù)組
@param view superView
*/
+ (void)showCustomAnimationWithImageArray:(NSArray *)imagArray onView:(UIView *)view;
/**
顯示自定義的 view涡驮,需手動(dòng)消失暗甥,(view 上可寫(xiě)動(dòng)畫(huà))
@param customView 自定義view
@param view superView
*/
+ (void)showCustomView:(UIView *)customView onView:(UIView *)view;
/**
手動(dòng)隱藏方法
*/
+ (void)hide;
/**
顯示加載進(jìn)度,需配合 setHUDDeterminateProgress 方法(在獲取進(jìn)度值的方法中調(diào)用),需手動(dòng)消失
@param title tips
@param view superView
*/
+ (void)showDeterminate:(NSString *)title onView:(UIView *)view;
/**
顯示 AnnularDeterminate 加載進(jìn)度,需配合 setHUDDeterminateProgress 方法(在獲取進(jìn)度值的方法中調(diào)用)捉捅,需手動(dòng)消失
@param title tips
@param view superView
*/
+ (void)showAnnularDeterminate:(NSString *)title onView:(UIView *)view;
/**
顯示 DeterminateHorizontalBar 加載進(jìn)度,需配合 setHUDDeterminateProgress 方法(在獲取進(jìn)度值的方法中調(diào)用)淋袖,需手動(dòng)消失
@param title tips
@param view superView
*/
+ (void)showDeterminateHorizontalBar:(NSString *)title onView:(UIView *)view;
/**
設(shè)置進(jìn)度的值,在顯示加載進(jìn)度時(shí)的進(jìn)度回調(diào)方法中使用
@param progress 進(jìn)度值
*/
+ (void)setHUDDeterminateProgress:(float)progress;
實(shí)現(xiàn)方法也很簡(jiǎn)單锯梁,就不貼了,可以去 gitHub 上看看 https://github.com/qyfeng009/MBHUD
看下效果吧
MBHUD.gif