027-Catagory-MBProgressHUD

#import 

@interface MBProgressHUD (JFProgressHUD)


/**
 MBProgressHUD提示信息,1秒后自动隐藏

 @param targetView  目标View
 @param message     提示信息
 */
+ (void)myi_promptHudWithShowHUDAddedTo:(UIView *)targetView message:(NSString *)message;

/**
 加载view的HUD

 @param targetView 目标View
 */
+ (void)myi_loadHudAddTo:(UIView *)targetView;

/**
 MBProgressHUD提示信息,1秒后自动隐藏
 
 @param targetView  目标View
 @param message     提示信息
 @param complete 隐藏后回调方法
 */
+ (void)myi_promptHudWithShowHUDAddedTo:(UIView *)targetView message:(NSString *)message complete:(void (^)())complete;

@end
#import "MBProgressHUD+JFProgressHUD.h"

@implementation MBProgressHUD (JFProgressHUD)

/// MBProgressHUD提示信息,1秒后自动隐藏
+ (void)myi_promptHudWithShowHUDAddedTo:(UIView *)targetView message:(NSString *)message {
    MBProgressHUD *hud = [[MBProgressHUD alloc] init];
    hud = [MBProgressHUD showHUDAddedTo:targetView animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.label.text = message;
    
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    [hud hideAnimated:YES afterDelay:1.0];
}

+ (void)myi_loadHudAddTo:(UIView *)targetView {
    MBProgressHUD *hud = [[MBProgressHUD alloc] init];
    hud = [MBProgressHUD showHUDAddedTo:targetView animated:YES];
}

+ (void)myi_promptHudWithShowHUDAddedTo:(UIView *)targetView message:(NSString *)message complete:(void (^)())complete {
    MBProgressHUD *hud = [[MBProgressHUD alloc] init];
    hud = [MBProgressHUD showHUDAddedTo:targetView animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.label.text = message;
    
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    [hud hideAnimated:YES afterDelay:1.0];
    [NSThread sleepForTimeInterval:1.0];
    complete();
}

@end

你可能感兴趣的:(027-Catagory-MBProgressHUD)