AFN和MBProgressHUD组合使用
2019-01-11 本文已影响12人
王欣12138
+ (MBProgressHUD *)hud {
MBProgressHUD *hud = objc_getAssociatedObject(self, _cmd);
if (!hud) {
hud = [[MBProgressHUD alloc] initWithView:kLastWindow];
hud.label.text = @"正在加载";
hud.contentColor = [UIColor whiteColor];
hud.bezelView.color = [UIColor blackColor];
objc_setAssociatedObject(self, _cmd, hud, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return hud;
}
+ (MBProgressHUD *)shareHud {
MBProgressHUD *hud = [self hud];
[kLastWindow addSubview:hud];
[hud showAnimated:YES];
return hud;
}
//初始化方法
MBProgressHUD *hud = [self shareHud];
//隐藏方法
[hud hideAnimated:YES];