如何使用mbprogresshud

如何使用mbprogresshud,第1张

//方式1.直接在View上showHUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain]HUD.delegate = self//常用的设置//小矩形的背景色HUD.color = [UIColor clearColor]//这儿表示无背景//显示的文字HUD.labelText = @"Test"//细节文字HUD.detailsLabelText = @"Test detail"//是否有庶罩HUD.dimBackground = YES[HUD hide:YES afterDelay:2]//只显示文字MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]hud.mode = MBProgressHUDModeTexthud.labelText = @"Some message..."hud.margin = 10.fhud.yOffset = 150.fhud.removeFromSuperViewOnHide = YES[hud hide:YES afterDelay:3]//方式2.initWithView//use blockHUD = [[MBProgressHUD alloc] initWithView:self.view][self.view addSubview:HUD]HUD.labelText = @"Test"[HUD showAnimated:YES whileExecutingBlock:^{NSLog(@"%@",@"do somethings....")[self doTask]} completionBlock:^{[HUD removeFromSuperview][HUD release]}]//圆形进度条HUD = [[MBProgressHUD alloc] initWithView:self.view][self.view addSubview:HUD]HUD.mode = MBProgressHUDModeAnnularDeterminateHUD.delegate = selfHUD.labelText = @"Loading"[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES]//自定义viewHUD = [[MBProgressHUD alloc] initWithView:self.view]HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease]// Set custom view modeHUD.mode = MBProgressHUDModeCustomViewHUD.delegate = selfHUD.labelText = @"Completed"[HUD show:YES][HUD hide:YES afterDelay:3]

导库

使用CocoaPads安装第三方库

PS:显示提示框的时候,一般不允许用户交互,就是做其他 *** 作,如点击其他按钮,因为默认就是允许交互,所以这个一定要设置下

Demo地址

MBProgressHUD和SVProgressHUD的区别:

svprogresshud 使用起来很方便,但 可定制 差一些,看它的接口貌似只能添加一个全屏的HUD,不能把它添加到某个视图上面去.

mbprogresshud 功能全一些,可定制 高一些,而且可以指定加到某一个View上去.用起来可能就没上面那个方便了.

具体还要看你的使用场景.


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11274378.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存