1. 程式人生 > >常用宏定義 - 設置加載提示框

常用宏定義 - 設置加載提示框

bject 三方 def tst rom obj uiscreen ted avi


1、第三方框架:Toast

/** 第三方框架:Toast */
#define kToast(str)              CSToastStyle *style = [[CSToastStyle alloc] initWithDefaultStyle]; [kWindow  makeToast:str duration:0.6 position:CSToastPositionCenter style:style];kWindow.userInteractionEnabled = NO; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{kWindow.userInteractionEnabled = YES;});

2、第三方框架:MBProgressHUD

// 加載
#define kShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
// 收起加載
#define HideNetworkActivityIndicator()      [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
// 設置加載
#define NetworkActivityIndicatorVisible(x)  [UIApplication sharedApplication].networkActivityIndicatorVisible = x

#define kWindow [UIApplication sharedApplication].keyWindow

#define kBackView         for (UIView *item in kWindow.subviews) { if(item.tag == 10000) { [item removeFromSuperview]; UIView * aView = [[UIView alloc] init]; aView.frame = [UIScreen mainScreen].bounds; aView.tag = 10000; aView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; [kWindow addSubview:aView]; } } 
#define kShowHUDAndActivity kBackView;[MBProgressHUD showHUDAddedTo:kWindow animated:YES];kShowNetworkActivityIndicator()


#define kHiddenHUD [MBProgressHUD hideAllHUDsForView:kWindow animated:YES]

#define kRemoveBackView         for (UIView *item in kWindow.subviews) { if(item.tag == 10000) { [UIView animateWithDuration:0.4 animations:^{ item.alpha = 0.0; } completion:^(BOOL finished) { [item removeFromSuperview]; }]; } } 
#define kHiddenHUDAndAvtivity kRemoveBackView;kHiddenHUD;HideNetworkActivityIndicator()

常用宏定義 - 設置加載提示框