MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
// 隐藏时候从父控件中移除
hud.removeFromSuperViewOnHide = YES;
// YES代表需要蒙版效果(去掉半透明蒙版)
hud.dimBackground = NO;
1 背景颜色改变
//修改框背景颜色
hud.bezelView.style = MBProgressHUDBackgroundStyleBlur;
hud.bezelView.backgroundColor=[UIColor blackColor];
2 修改字体颜色
hud.label.textColor =[UIColor whiteColor];
3 修改菊花颜色
typedef NS_ENUM(NSInteger, MBProgressHUDMode) {
/// UIActivityIndicatorView.
MBProgressHUDModeIndeterminate,
/// A round, pie-chart like, progress view.
MBProgressHUDModeDeterminate,
/// Horizontal progress bar.
MBProgressHUDModeDeterminateHorizontalBar,
/// Ring-shaped progress view.
MBProgressHUDModeAnnularDeterminate,
/// Shows a custom view.
MBProgressHUDModeCustomView,
/// Shows only labels.
MBProgressHUDModeText
};
// 默认指示器是菊花
hud.mode = MBProgressHUDModeIndeterminate;
进入 #import "MBProgressHUD.m" 在 400行 添加一个自定义的覆盖
//!!! 添加自定义菊花
UIActivityIndicatorView *activI =[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activI.frame = indicator.bounds;
[indicator addSubview:activI];
[activI startAnimating];
//小菊花 一共有下面几种颜色选择 第一个大白 第二个 小白 第三个灰色
UIActivityIndicatorViewStyleWhiteLarge,
UIActivityIndicatorViewStyleWhite,
UIActivityIndicatorViewStyleGray __TVOS_PROHIBITED,
//方法封装
- (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.label.textColor =[UIColor whiteColor];
// 隐藏时候从父控件中移除
hud.removeFromSuperViewOnHide = YES;
// YES代表需要蒙版效果
hud.dimBackground = NO;
// 默认指示器是菊花
hud.mode = MBProgressHUDModeIndeterminate;
// */
// @property (nonatomic, strong) UIColor *progressTintColor;
//
// MBProgressHUDAnimationFade,
// MBProgressHUDAnimationZoom,
// MBProgressHUDAnimationZoomOut,
// MBProgressHUDAnimationZoomIn
// hud.backgroundColor = [UIColor blueColor];
// hud.alpha = 0.8;
//修改框背景颜色
hud.bezelView.style = MBProgressHUDBackgroundStyleBlur;
hud.bezelView.backgroundColor=[UIColor blackColor];
hud.mode = MBProgressHUDModeIndeterminate;
// hud.backgroundColor =[UIColor whiteColor];
// hud.bezelView.backgroundColor =[UIColor blackColor];
// hud.backgroundView.backgroundColor =[UIColor whiteColor];
// hud.activityIndicatorColor = [UIColor whiteColor];
return hud;
}