SVProgressHUD 用法

介绍一款显示加载效果的第三方库,使用很简单,先看效果

特点

1. 提示当前的状态,如:网络传输、提交中、操作成功或失败等等.
 
2. 可是设置提示的 pop layer 是否为 model,就是,提示的时间是否允许用户做其他操作
 
3. 可以设置 背景色 和 自定义提示的内容
 
4. 使用起来非常简洁,代码量非常少
如何使用
1 去github上下载SVProgressHUD ,地址https://github.com/samvermette/SVProgressHUD
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 全部设置和方法
@interface SVProgressHUD : UIView

#pragma mark - Customization

+ (void)setBackgroundColor:(UIColor*)color;                 // default is [UIColor whiteColor]
+ (void)setForegroundColor:(UIColor*)color;                 // default is [UIColor blackColor]
+ (void)setCornerRadius:(CGFloat)cornerRadius;              // default is 14 pt
+ (void)setRingThickness:(CGFloat)width;                    // 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; // default is SVProgressHUDMaskTypeNone
+ (void)setViewForExtension:(UIView*)view;                  // default is nil, only used if #define SV_APP_EXTENSIONS is set

#pragma mark - Show Methods

+ (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; // change the HUD loading status while it's showing

// 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;
+ (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;

+ (void)setOffsetFromCenter:(UIOffset)offset;
+ (void)resetOffsetFromCenter;

+ (void)popActivity; // decrease activity count, if activity count == 0 the HUD is dismissed
+ (void)dismiss;

+ (BOOL)isVisible;

@end
原文地址:https://www.cnblogs.com/ZhaoJingyuLLH/p/4749962.html