1. 程式人生 > >iOS——載入進度示的SVProgressHUD 用法

iOS——載入進度示的SVProgressHUD 用法

SVProgressHUD 是一個第三方的控制元件,是一個彈出提示層,用來提示 網路載入 或 提示對錯,看下面圖,你就明白了:

那麼,SVProgressHUD 都有什麼特點呢: 1. 提示當前的狀態,如:網路傳輸、提交中、操作成功或失敗等等. 2. 可是設定提示的 pop layer 是否為 model,就是,提示的時間是否允許使用者做其他操作 3. 可以設定 背景色 和 自定義提示的內容 4. 使用起來非常簡潔,程式碼量非常少 那麼如何使用 SVProgressHUD 呢: 1. 官網下載程式碼,並放入到專案中 2. 在使用到的 專案 裡面,加入引用  #import "SVProgressHUD.h" 3. 在需要提示的地方,加入呼叫程式碼 ,如:     [SVProgressHUD showWithStatus:@"載入中..." maskType:SVProgressHUDMaskTypeGradient] 4. 在需要隱藏的地方,加入隱藏當前提示的程式碼,如:[SVProgressHUD dismiss] SVProgressHUD 常用方法介紹: 1. + (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType 呼叫 SVProgressHUD,並自定義 提示的內容 和 提示層的樣式 2. + (void)dismiss 關閉當前提示 SVProgressHUDMaskType 介紹: 1. SVProgressHUDMaskTypeNone : 當提示顯示的時間,使用者仍然可以做其他操作,比如View 上面的輸入等 2. SVProgressHUDMaskTypeClear : 使用者不可以做其他操作 3. SVProgressHUDMaskTypeBlack : 使用者不可以做其他操作,並且背景色是黑色 4. SVProgressHUDMaskTypeGradient : 使用者不可以做其他操作,並且背景色是漸變的 SVProgressHUD 全部方法: 複製程式碼
+ (void)show;
+ (void)showWithStatus:(NSString*)status;
+ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
 
+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showSuccessWithStatus:(NSString *)string duration:(NSTimeInterval)duration;
+ (void)showErrorWithStatus:(NSString *)string; + (void)showErrorWithStatus:(NSString *)string duration:(NSTimeInterval)duration; + (void)setStatus:(NSString*)string; // change the HUD loading status while it's showing + (void)dismiss; // simply dismiss the HUD with a fade+scale out animation + (void
)dismissWithSuccess:(NSString*)successString; // also displays the success icon image + (void)dismissWithSuccess:(NSString*)successString afterDelay:(NSTimeInterval)seconds; + (void)dismissWithError:(NSString*)errorString; // also displays the error icon image + (void)dismissWithError:(NSString*)errorString afterDelay:(NSTimeInterval)seconds; + (BOOL)isVisible;
複製程式碼