Skip to content

Latest commit

 

History

History
71 lines (60 loc) · 1.72 KB

README.md

File metadata and controls

71 lines (60 loc) · 1.72 KB

MKLoadingHUD

自定义Loading HUD

效果展示:

使用方法:

导入头文件

#import "MKLoadingHUD.h"

显示 HUD


普通的 HUD

//以下三个方法,2.0 秒后自动隐藏
+ (void)showToast:(NSString *)status;
+ (void)showImage:(UIImage *)image;
+ (void)showSuccessWithStatus:(NSString *)status;
+ (void)showErrorWithStatus:(NSString *)status;

自定义的 HUD,需要手动 +hide

+ (void)showCustomView:(UIView *)customView;
+ (void)showCustomView:(UIView *)customView andStatus:(NSString *)status;
+ (void)showStatus:(NSString *)status andCustomView:(UIView *)customView inView:(UIView *)view;

+ (void)hide;
+ (void)hideDelay:(NSTimeInterval)seconds;

自定义的代码先用+setConfig,再调喜欢的+show方法就可以了

[MKLoadingHUD setConfig:^(MKLoadingHUD *hud) {
  hud.defaultMaskType = MKLoadingHUDMaskTypeGradient;
}];

[MKLoadingHUD showSuccessWithStatus:@"哇,渐变色!"];

目前支持的自定义属性如下:

minimumSize - 限制 HUD 的最小显示尺寸
statusFont  - HUD 的文字 font
customViewTintColor - HUD 的自定义 view 的 tintclor

typedef NS_ENUM(NSInteger, MKLoadingHUDStyle) {
    /// 白底黑字
    MKLoadingHUDStyleLight,
    /// 黑底白字
    MKLoadingHUDStyleDark,
};

typedef NS_ENUM(NSUInteger, MKLoadingHUDMaskType) {
    /// 背景透明,允许事件穿透
    MKLoadingHUDMaskTypeNone = 1,
    /// 背景透明,不允许事件穿透
    MKLoadingHUDMaskTypeClear,
    /// 背景半黑,不允许事件穿透
    MKLoadingHUDMaskTypeBlack,
    /// 背景渐变,不允许事件穿透
    MKLoadingHUDMaskTypeGradient
};

PS:素材来自网络,此处谨做学习使用,如有侵权,请告知我,我会尽快删除~