平常寫代碼鳄虱。我們經(jīng)常會(huì)使用到MBProgressHUD,但是隨著版本的更新蒜田,我發(fā)現(xiàn)好多屬性都被廢棄,這里貼上最新詳解膜廊,希望能夠?qū)τ行枰男』锇橛兴鶐椭?/h2>
//hud = [[MBProgressHUD alloc] init];
//[self.view addSubview:HUD];
hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//hud = [[MBProgressHUD alloc] init];
//[self.view addSubview:HUD];
hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//1.設(shè)置提示框類型
hud.mode = MBProgressHUDModeIndeterminate; //菊花乏沸,默認(rèn)
//2.設(shè)置有遮罩
// hud.dimBackground = NO; 已廢棄,目前需要自定義hud.backgroundColor = [UIColor blackColor]; //設(shè)置遮罩背景色,默認(rèn)為透明
//3.設(shè)置背景框的透明度
// HUD.opacity = 1;默認(rèn)0.8,已廢棄hud.alpha = 0.5;//設(shè)置遮罩透明度
//4,設(shè)置背景框的圓角值爪瓜,
//? hud.cornerRadius = 20.0;默認(rèn)是10,已廢棄hud.bezelView.layer.cornerRadius = 20.0;//設(shè)置背景框圓角
//5.設(shè)置提示信息 信息顏色蹬跃,字體
//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,設(shè)置提示信息詳情 詳情顏色,字體
//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翁都,設(shè)置菊花顏色
// 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設(shè)置一個(gè)漸變層
hud.dimBackground = YES; //已廢棄谅猾,現(xiàn)需自定義
//8設(shè)置動(dòng)畫的模式
hud.mode = MBProgressHUDModeIndeterminate;//菊花柄慰,默認(rèn)值
//hud.mode = MBProgressHUDModeDeterminate; // 圓餅,餅狀圖
//hud.mode = MBProgressHUDModeDeterminateHorizontalBar; //進(jìn)度條
// hud.mode = MBProgressHUDModeAnnularDeterminate;? //圓環(huán)作為進(jìn)度條
// hud.mode = MBProgressHUDModeCustomView;? ? ? //需要自定義試圖時(shí)候設(shè)置成這個(gè)
//hud.mode = MBProgressHUDModeText;? ? //只顯示文本
//9.設(shè)置提示框的相對(duì)于父視圖中心點(diǎn)的便宜税娜,正值 向右下偏移先煎,負(fù)值左上
//hud.xOffset = -80;//已廢棄
// hud.yOffset = -100; //已廢棄[hud setOffset:CGPointMake(-80, -100)];
//10.設(shè)置各個(gè)元素距離矩形邊框的距離
hud.margin = 0;
//? 11? 背景框的最小大小
hud.minSize = CGSizeMake(50, 50);
//12設(shè)置背景框的實(shí)際大小? readonly
// CGSize size = hud.frame.size;
//13是否強(qiáng)制背景框?qū)捀呦嗟?/b>
hud.square = YES;
//14設(shè)置最短顯示時(shí)間,為了避免顯示后立即被隱藏? 默認(rèn)是0
hud.minShowTime = 10;
//15 設(shè)置顯示和隱藏動(dòng)畫類型? 有三種動(dòng)畫效果巧涧,如下
//? ? hud.animationType = MBProgressHUDAnimationFade; //默認(rèn)類型的薯蝎,漸變
//? ? hud.animationType = MBProgressHUDAnimationZoomOut; //HUD的整個(gè)view后退 然后逐漸的后退
hud.animationType = MBProgressHUDAnimationZoomIn; //和上一個(gè)相反,前近谤绳,最后淡化消失
//16設(shè)置隱藏的時(shí)候是否從父視圖中移除占锯,默認(rèn)為no
hud.removeFromSuperViewOnHide = NO;
//17進(jìn)度指示器 默認(rèn)是0 取值從0.0--1.0
hud.progress = 0.5;
//18.隱藏時(shí)候的回調(diào)袒哥,隱藏動(dòng)畫結(jié)束之后
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];
以上的總結(jié)對(duì)我們平時(shí)一般的使用應(yīng)該都是需要的,感謝某位大神對(duì)以前版本的總結(jié)消略。