美文网首页codeTools
027-Catagory-MBProgressHUD

027-Catagory-MBProgressHUD

作者: ArrQing | 来源:发表于2017-03-06 09:04 被阅读2次
#import <MBProgressHUD/MBProgressHUD.h>

@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

    本文链接:https://www.haomeiwen.com/subject/lyyygttx.html