平常写代码。我们经常会使用到MBProgressHUD,但是随着版本的更新,我发现好多属性都被废弃,这里贴上最新详解,希望能够对有需要的小伙伴有所帮助。
//hud = [[MBProgressHUD alloc] init];
//[self.view addSubview:HUD];
hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//1.设置提示框类型
hud.mode = MBProgressHUDModeIndeterminate; //菊花,默认
//2.设置有遮罩
// hud.dimBackground = NO; 已废弃,目前需要自定义hud.backgroundColor = [UIColor blackColor]; //设置遮罩背景色,默认为透明
//3.设置背景框的透明度
// HUD.opacity = 1;默认0.8,已废弃hud.alpha = 0.5;//设置遮罩透明度
//4,设置背景框的圆角值,
// hud.cornerRadius = 20.0;默认是10,已废弃hud.bezelView.layer.cornerRadius = 20.0;//设置背景框圆角
//5.设置提示信息 信息颜色,字体
//hud.labelColor = [UIColor blueColor];已废弃,label.textColor取代hud.label.textColor = [UIColor blueColor];
//hud.labelFont = [UIFont systemFontOfSize:13];已废弃,label.font取代hud.label.font = [UIFont systemFontOfSize:13];
//hud.labelText = @"Loading...";已废弃,lable.text取代hud.label.text = @"Loading...";
//6,设置提示信息详情 详情颜色,字体
//hud.detailsLabelColor = [UIColor blueColor];已废弃,detailsLabel.textColor取代hud.detailsLabel.textColor = [UIColor blueColor];
//hud.detailsLabelFont = [UIFont systemFontOfSize:13];detailsLabel.font取代hud.detailsLabel.font = [UIFont systemFontOfSize:13];
//hud.detailsLabelText = @"LoadingLoading...";已废弃,detailsLabel.text取代hud.detailsLabel.text = @"loading...";
//6,设置菊花颜色
// hud.activityIndicatorColor = [UIColor blackColor];//Use UIAppearance to customize UIActivityIndicatorView. E.g.: [UIActivityIndicatorView appearanceWhenContainedIn:[MBProgressHUD class], nil].color = [UIColor redColor];
//[UIActivityIndicatorView appearanceWhenContainedIn:[MBProgressHUD class], nil].color = [UIColor redColor];已废弃,用以下取代[UIActivityIndicatorView appearanceWhenContainedInInstancesOfClasses:@[[MBProgressHUD class]]].color = [UIColor redColor];
//7设置一个渐变层
hud.dimBackground = YES; //已废弃,现需自定义
//8设置动画的模式
hud.mode = MBProgressHUDModeIndeterminate;//菊花,默认值
//hud.mode = MBProgressHUDModeDeterminate; // 圆饼,饼状图
//hud.mode = MBProgressHUDModeDeterminateHorizontalBar; //进度条
// hud.mode = MBProgressHUDModeAnnularDeterminate; //圆环作为进度条
// hud.mode = MBProgressHUDModeCustomView; //需要自定义试图时候设置成这个
//hud.mode = MBProgressHUDModeText; //只显示文本
//9.设置提示框的相对于父视图中心点的便宜,正值 向右下偏移,负值左上
//hud.xOffset = -80;//已废弃
// hud.yOffset = -100; //已废弃[hud setOffset:CGPointMake(-80, -100)];
//10.设置各个元素距离矩形边框的距离
hud.margin = 0;
// 11 背景框的最小大小
hud.minSize = CGSizeMake(50, 50);
//12设置背景框的实际大小 readonly
// CGSize size = hud.frame.size;
//13是否强制背景框宽高相等
hud.square = YES;
//14设置最短显示时间,为了避免显示后立即被隐藏 默认是0
hud.minShowTime = 10;
//15 设置显示和隐藏动画类型 有三种动画效果,如下
// hud.animationType = MBProgressHUDAnimationFade; //默认类型的,渐变
// hud.animationType = MBProgressHUDAnimationZoomOut; //HUD的整个view后退 然后逐渐的后退
hud.animationType = MBProgressHUDAnimationZoomIn; //和上一个相反,前近,最后淡化消失
//16设置隐藏的时候是否从父视图中移除,默认为no
hud.removeFromSuperViewOnHide = NO;
//17进度指示器 默认是0 取值从0.0--1.0
hud.progress = 0.5;
//18.隐藏时候的回调,隐藏动画结束之后
hud.completionBlock = ^{
NSLog(@"11");
};
// [hud show:YES];//已废弃[hud showAnimated:YES];
//两种隐藏的方法
// [hud hide:YES];//已废弃[hud hideAnimated:YES];
// [hud hide:YES afterDelay:5];//已废弃[hud hideAnimated:YES afterDelay:5];
以上的总结对我们平时一般的使用应该都是需要的,感谢某位大神对以前版本的总结。