123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- //
- // MBProgressHUD+Extension.m
- // djlt
- //
- // Created by macmini04 on 16/1/18.
- // Copyright © 2016年 com.topsage.djlt. All rights reserved.
- //
- #import "MBProgressHUD+Extension.h"
- @implementation MBProgressHUD (Extension)
- + (instancetype)showLoadingAddedToView:(UIView *)view {
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
-
- hud.label.text = @"加载中";
- hud.label.textColor = [UIColor JZColorWithHex:0x333333];
- hud.label.font = [UIFont boldSystemFontOfSize:17];
- hud.bezelView.backgroundColor = [UIColor whiteColor];
- hud.bezelView.layer.cornerRadius = 14;
- hud.backgroundColor = [UIColor JZColorWithHex:0x000000 alpha:0.3];
-
- return hud;
- }
- + (instancetype)showTip:(NSString *)tip {
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
-
- hud.mode = MBProgressHUDModeText;
- hud.label.text = tip;
- hud.label.numberOfLines=0;
- hud.label.textColor = [UIColor whiteColor];
- hud.label.font = [UIFont boldSystemFontOfSize:17];
- hud.bezelView.backgroundColor = [UIColor blackColor];
- hud.bezelView.layer.cornerRadius = 14;
- hud.backgroundColor = [UIColor JZColorWithHex:0x000000 alpha:0.3];
-
- [hud hideAnimated:YES afterDelay:1.5];
-
- return hud;
- }
- + (instancetype)showTip:(NSString *)tip time:(NSTimeInterval)time {
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
-
- hud.mode = MBProgressHUDModeIndeterminate;
- hud.contentColor = [UIColor whiteColor];
- hud.label.text = tip;
- hud.label.numberOfLines=0;
- hud.label.textColor = [UIColor whiteColor];
- hud.label.font = [UIFont boldSystemFontOfSize:17];
- hud.bezelView.backgroundColor = [UIColor blackColor];
- hud.bezelView.layer.cornerRadius = 14;
- hud.backgroundColor = [UIColor JZColorWithHex:0x000000 alpha:0.3];
-
- [hud hideAnimated:YES afterDelay:time];
-
- return hud;
- }
- /** 显示信息 */
- + (MBProgressHUD *)showMessage:(NSString *)message {
- return [self showMessage:message toView:nil];
- }
- + (MBProgressHUD *)showMessage:(NSString *)message toView:(UIView *)view {
- if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
-
- // 快速显示一个提示信息
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
- hud.label.text = message;
- hud.mode =MBProgressHUDModeText;
- // 隐藏时候从父控件中移除
- hud.removeFromSuperViewOnHide = YES;
-
- // 1秒之后再消失
- [hud hideAnimated:YES afterDelay:2];
- return hud;
- }
- + (void)show:(NSString *)text icon:(NSString *)icon view:(UIView *)view {
- if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
-
- // 快速显示一个提示信息
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
- hud.label.text = text;
- // 设置图片
- hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];
- // 再设置模式
- hud.mode = MBProgressHUDModeCustomView;
-
- // hud.mode = MBProgressHUDModeAnnularDeterminate; // 圆形进度条
-
- // 隐藏时候从父控件中移除
- hud.removeFromSuperViewOnHide = YES;
-
- // 1秒之后再消失
- [hud hideAnimated:YES afterDelay:1];
- }
- /** 成功 */
- + (void)showSuccess:(NSString *)success {
- [self showSuccess:success toView:nil];
- }
- + (void)showSuccess:(NSString *)success toView:(UIView *)view
- {
- [self show:success icon:@"success.png" view:view];
- }
- /** 错误 */
- + (void)showError:(NSString *)error {
- [self showError:error toView:nil];
- }
- + (void)showError:(NSString *)error toView:(UIView *)view{
- [self show:error icon:@"error.png" view:view];
- }
- /** 隐藏 */
- + (void)hideHUD {
- [self hideHUDForView:nil];
- }
- + (void)hideHUDForView:(UIView *)view {
- if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
- // 隐藏时候从父控件中移除
- [self hideHUDForView:view animated:YES];
-
- }
- @end
|