一,工程图。
二,代码。
ViewController.m
class="cnblogs_code_copy" style="font-size: 18px">#import "ViewController.h"
#import "MBProgressHUD.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//初始化MBProgressHUD
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.labelText = @"加载中";
}
//点击任何处隐藏MBProgressHUD
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end