先导入第三方
MBProgressHUD
在VC.m里导入头文件
MBProgressHUD.h
VC.M
//显示提示框
-(void)showMBAlertwWithMessage:(NSString *)msg{
MBProgressHUD *hud = [[MBProgressHUD alloc]initWithView:self.view];
//MBProgressHUDModeIndeterminate 菊花
hud.mode = MBProgressHUDModeText;
hud.labelText = msg;
[self.view addSubview:hud];
[hud show:YES];
[hud hide:YES afterDelay:2.0];
}
//需要的弹窗的时候
[self showMBAlertwWithMessage:@"弹出的文字内容"];
//显示等待指示器
MBProgressHUD *hud = [[MBProgressHUD alloc]initWithView:self.view];
hud.removeFromSuperViewOnHide = YES;
[self.view addSubview:hud];
[hud show:YES];
// 隐藏等待指示器
[hud hide:YES];
本文详细介绍了如何在iOS应用中使用MBProgressHUD库来显示加载框和提示消息。通过在ViewController中导入MBProgressHUD头文件,并调用自定义的方法showMBAlertwWithMessage和showMBProgressHUD,可以轻松实现加载指示器和弹窗的显示与隐藏。
1355

被折叠的 条评论
为什么被折叠?



