SVProgressHUD方法

第三方框架中關於HUD有MBProgressHUD和SVProgressHUD

我以爲會一種就能夠了,綜合前輩們的經驗選擇了後者,而後就花了一點時間,把他的方法都看了一下。在這裏用做記錄,供本身鞏固和查閱。app

方法

SVProgressHUD因此的方法都是類方法,而且對象是經過單例建立。因爲方法都是經過類名調用,簡單明瞭。框架

基本方法
+ (void)show; 顯示:狀態是一個迅速轉動的圈 + (void)showWithMaskType:(SVProgressHUDMaskType)maskType; 顯示而且帶着一個狀態 + (void)showWithStatus:(NSString*)status; 顯示而且帶着文字 + (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType; + (void)showProgress:(float)progress; //顯示進度:狀態是一個進度圈 + (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType; + (void)showProgress:(float)progress status:(NSString*)status; + (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType; + (void)setStatus:(NSString*)string; // 改變正顯示着的HUD的文字 // stops the activity indicator, shows a glyph + status, and dismisses HUD a little bit later + (void)showInfoWithStatus:(NSString *)string; //顯示消息信息,其實就是中心圖片更換了 + (void)showInfoWithStatus:(NSString *)string maskType:(SVProgressHUDMaskType)maskType; + (void)showSuccessWithStatus:(NSString*)string; //顯示成功消息 + (void)showSuccessWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType; + (void)showErrorWithStatus:(NSString *)string; //顯示錯誤消息 + (void)showErrorWithStatus:(NSString *)string maskType:(SVProgressHUDMaskType)maskType; // use 28x28 white pngs + (void)showImage:(UIImage*)image status:(NSString*)status; //顯示本身設置的圖片,圖片大小事28 * 28 px + (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType; + (void)setOffsetFromCenter:(UIOffset)offset; //距離中心點的偏移量 + (void)resetOffsetFromCenter; //返回中心點 + (void)popActivity; // 消除一個HUD,根據其實現方法若是前面有執行了好幾回show方法,若是給定的progress == 0 或者 pregress < 0那樣就會讓使一個參數+1,執行這個方法會使那個參數-1,若是參數==0時 執行dismiss方法。 + (void)dismiss; 消失 + (BOOL)isVisible; 是否正在顯示 

關於HUD的屬性配置

+ (void)setBackgroundColor:(UIColor*)color; //背景顏色 // default is [UIColor whiteColor] + (void)setForegroundColor:(UIColor*)color; //progress 和 label顏色 // default is [UIColor blackColor] + (void)setRingThickness:(CGFloat)width; //progress 寬度 // default is 4 pt + (void)setFont:(UIFont*)font; //字體 // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline] + (void)setInfoImage:(UIImage*)image; //消息的圖片 // default is the bundled info image provided by Freepik + (void)setSuccessImage:(UIImage*)image; //成功時的圖片 // default is the bundled success image provided by Freepik + (void)setErrorImage:(UIImage*)image; //失敗時的圖片 // default is the bundled error image provided by Freepik + (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; //當HUD顯示時,用戶是否能夠點擊其餘控件// default is SVProgressHUDMaskTypeNone SVProgressHUDMaskTypeNone = 1, // 容許用戶進行其餘用戶操做 SVProgressHUDMaskTypeClear, // 不容許用戶進行其餘用戶操做 SVProgressHUDMaskTypeBlack, // 不容許用戶進行其餘用戶操做,而且背景是黑色的 SVProgressHUDMaskTypeGradient // 容許用戶進行其餘用戶操做,而且背景是漸變的黑色 + (void)setViewForExtension:(UIView*)view; //能夠延展一個圖片必須設置#define SV_APP_EXTENSIONS 

關於HUD的通知

extern NSString * const SVProgressHUDDidReceiveTouchEventNotification; 在HUD外點擊 extern NSString * const SVProgressHUDDidTouchDownInsideNotification; 在HUD中點擊 extern NSString * const SVProgressHUDWillDisappearNotification; 將要顯示 extern NSString * const SVProgressHUDDidDisappearNotification; 已經顯示 extern NSString * const SVProgressHUDWillAppearNotification; 將要消失 extern NSString * const SVProgressHUDDidAppearNotification; 已經消失 extern NSString * const SVProgressHUDStatusUserInfoKey; HUD的狀態 

在通知中userInfo字典中存儲了HUD的狀態,其key爲SVProgressHUDStatusUserInfoKeyide

MBProgressHUD的基本使用

/** * 類方法 */ /* MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; @weakify(hud) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ @strongify(hud) [MBProgressHUD hideAllHUDsForView:self.view animated:YES]; }); */ /** * 實例方法 */ MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.view]; //顯示hud的模式 hud.mode = MBProgressHUDModeDeterminate; //背景顏色 hud.color = [UIColor redColor]; //主標題 hud.labelText = @"主標題"; //副標題 hud.detailsLabelText = @"副標題"; //顯示、隱藏時的動畫樣式 hud.animationType = MBProgressHUDAnimationZoomIn; //當mode的屬性是跟進度相關時,就能夠設置progress的值,實現實時進度的顯示 hud.progress = 0.8; // HUD的相對於父視圖 x 的偏移,默認居中 // hud.xOffset = 50; // hud.yOffset = 50; //是否顯示蒙板 hud.dimBackground = YES; //HUD內部視圖相對於HUD的內邊距 hud.margin = 50; //HUD的圓角半徑 hud.cornerRadius = 20; //最小的顯示時間 hud.minShowTime = 3.0; // HUD的最小尺寸 hud.minSize = CGSizeMake(300, 300); // 代理中只有一個方法,即得到HUD隱藏後的時刻 // hud.delegate = self; [self.view addSubview:hud]; [hud showAnimated:YES whileExecutingBlock:^{ //hud執行期間 NSLog(@"執行期間"); } onQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) completionBlock:^{ //hud執行完畢 NSLog(@"執行完畢"); }]; } 
相關文章
相關標籤/搜索