一、網上找到MBProgressHUD.h .m文件拖到咱們新建的項目裏面
二、在咱們的項目裏面新建一個類BaseViewController 繼承自UIViewController
三、在BaseViewController。h中定義兩個方法,一個顯示等待視圖,一個隱藏等待視圖
- (void)showProgress;
- (void)hidenProgress;
四、在BaseViewController。m裏面導入MBProgressHUD.h
1⃣️、定義一個全局變量屬性
{
MBProgressHUD *HUD;
}
2⃣️、實現,h文件裏定義的兩個方法
- (void)showProgress
{
HUD = [[MBProgressHUD alloc]initWithView:self.view];
[self.view addSubview:HUD];
[HUD show:YES];
}
- (void)hidenProgress
{
[HUD hide:YES];
}
五、在viewController。h裏面設置,使ViewController 繼承自BaseViewController
viewController。h中
六、在viewController。m中直接調用顯示影藏的方法即可