iOS_第3方類庫MBprogressHUD

來源:互聯網
上載者:User

iOS_第3方類庫MBprogressHUD

1,將下載好的第3方類庫MBprogressHUD源碼包加入到工程(其實就是一個.h和.m檔案)

2,進入工程的Build Phases,將源碼包裡面的所有.m檔案全部添加到工程

3,添加第3方類庫的主標頭檔"MBProgressHUD.h"


顯示代碼:

// 一開始載入就,顯示提示條    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:webView animated:YES];    // 加一層蒙版    hud.dimBackground = YES;    hud.labelText = @"頁面載入中...";
隱藏代碼:

// 一旦載入完畢,就隱藏提示條    [MBProgressHUD hideAllHUDsForView:webView animated:YES];

自訂顯示圖片:

// 抽取的,僅供分類內部調用+ (void) showMsg:(NSString *)msg imgName:(NSString *)imgName{    // 顯示到主視窗中    MBProgressHUD *hud =[MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];        // 顯示模式,改成customView,即顯示自訂圖片(mode設定,必須寫在customView賦值之前)    hud.mode = MBProgressHUDModeCustomView;            int delay = 1;       if ([imgName isEqualToString:@"error.png"]) {        // 錯誤時,提示3秒鐘        delay = 3;    }        imgName = [NSString stringWithFormat:@"MBProgressHUD.bundle/%@",imgName];    // 設定要顯示 的自訂的圖片    hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imgName]];    // 顯示的文字,比如:載入失敗...載入中...    hud.labelText = msg;    // 標誌:必須為YES,才可以隱藏,  隱藏的時候從父控制項中移除    hud.removeFromSuperViewOnHide = YES;    // 3秒後自動隱藏        log(@"%d",delay);    [hud hide:YES afterDelay:delay];}
其他常用屬性
  // 提示框的背景色  hud.color = [UIColor clearColor];//這兒表示無背景  // 提示下文的小文字  hud.detailsLabelText = @"detail";  // 陰影遮罩效果  hud.dimBackground = YES;  // 1秒之後隱藏[hud hide:YES afterDelay:1];  //只顯示文字   hud.mode = MBProgressHUDModeText;  // 外邊距 和 Y方向位移hud.margin = 0;  hud.yOffset = 0;  // 隱藏後從父控制項中移除hud.removeFromSuperViewOnHide = YES;  //圓形進度條  hud.mode = MBProgressHUDModeAnnularDeterminate;  




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.