SVProgressHUD控件使用

转载自:http://cht005288201307234627.iteye.com/blog/1927961


SVProgressHUD

博客分类:  ios
 

GitHub:https://github.com/samvermette/SVProgressHUD
SVProgressHUD和MBProgressHUD效果差不多,不过不需要使用协议,同时也不需要声明实例。
直接通过类方法进行调用即可:

1 [SVProgressHUD method]

 

可以使用以下方法来显示状态:

1
2
3
4
+ (void)show;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
+ (void)showWithStatus:(NSString*)string;
+ (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType;

 

如果需要明确的进度,则使用以下方法:

1
2
3
+ (void)showProgress:(CGFloat)progress;
+ (void)showProgress:(CGFloat)progress status:(NSString*)status;
+ (void)showProgress:(CGFloat)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;

 

 

通过dismiss方法来隐藏提示:

1 + (void)dismiss;

 

另外提供了以下方法用于显示状态,并在1秒后自动隐藏提示(使用的图标来源于Glyphish:http://www.glyphish.com/):

1
2
3
+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showErrorWithStatus:(NSString *)string;
+ (void)showImage:(UIImage*)image status:(NSString*)string;// use 28x28 white pngs 

 

Java代码   收藏代码
  1. #import "ViewController.h"  
  2. #import   
  3.   
  4. @interface ViewController ()  
  5.   
  6. @end  
  7.   
  8. @implementation ViewController  
  9.   
  10. - (void)viewDidLoad  
  11. {  
  12.     [super viewDidLoad];  
  13. }  
  14.   
  15.   
  16. - (void)didReceiveMemoryWarning  
  17. {  
  18.     [super didReceiveMemoryWarning];  
  19. }  
  20.   
  21. - (IBAction)show:(id)sender {  
  22.   //  [SVProgressHUD show];  
  23.    //SVProgressHUDMaskType 设置显示的样式  
  24.    [SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];  
  25.    [self performSelector:@selector(dismiss:) withObject:nil afterDelay:3];  
  26. }  
  27.   
  28. - (IBAction)showText:(id)sender {  
  29.     [SVProgressHUD showWithStatus:@"加载中,请稍后。。。"];  
  30.     [self performSelector:@selector(dismiss:) withObject:nil afterDelay:3];  
  31. }  
  32.   
  33. - (IBAction)showprogress:(id)sender {  
  34.     [SVProgressHUD showProgress:0 status:@"加载中"];  
  35.     [self performSelector:@selector(increateProgress) withObject:nil afterDelay:0.3];  
  36. }  
  37.   
  38.   
  39. static float progressValue = 0.0f;  
  40. - (void)increateProgress  
  41. {  
  42.     progressValue += 0.1;  
  43.     [SVProgressHUD showProgress:progressValue status:@"加载中"];  
  44.     if (progressValue < 1) {  
  45.          [self performSelector:@selector(increateProgress) withObject:nil afterDelay:0.3];  
  46.     }else{  
  47.         [self performSelector:@selector(dismiss:) withObject:nil afterDelay:0.4];  
  48.     }  
  49.   
  50. }  
  51.   
  52. - (IBAction)dismiss:(id)sender {  
  53.     [SVProgressHUD dismiss];  
  54. }  
  55.   
  56. - (IBAction)showSuccess:(id)sender {  
  57.     [SVProgressHUD showSuccessWithStatus:@"success"];  
  58.     [self performSelector:@selector(dismiss:) withObject:nil afterDelay:3];  
  59. }  
  60.   
  61. - (IBAction)showError:(id)sender {  
  62.     [SVProgressHUD showErrorWithStatus:@"error"];  
  63.     [self performSelector:@selector(dismiss:) withObject:nil afterDelay:3];  
  64. }  
  65.   
  66.   
  67. @end  

你可能感兴趣的:(iOS第三方类库)