SVProgressHUD使用简单方便
1、[SVProgressHUD show];
Untitled.gif
2、[SVProgressHUD showProgress:1];
Untitled.gif
3、[SVProgressHUD showInfoWithStatus:@"hello world"];
Untitled.gif
4、[SVProgressHUD showWithStatus:@"你好,世界"];
Untitled.gif
5、[SVProgressHUD showErrorWithStatus:@"没有网络"];
Untitled.gif
6、[SVProgressHUD showProgress:0.5 status:@"正在下载"];
Untitled.gif
7、[SVProgressHUD showSuccessWithStatus:@"提交成功"];
Untitled.gif
总结:
会根据字符串的长度确定显示时间
- showSuccessWithStatus
- showErrorWithStatus
- showInfoWithStatus
- (void)showImage:(UIImage)image status:(NSString)status
会一直保留的
- show
- showWithStatus
- showProgress
- showProgress:status:
可以用dismissWithDelay,进行延时取消,dismiss直接进行取消
我们可以自定义里面的一些属性,比如字体大小,提示图片等。可以自定的方法如下:
- (void)setDefaultStyle:(SVProgressHUDStyle)style; // default is SVProgressHUDStyleLight
- (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone
- (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type; // default is SVProgressHUDAnimationTypeFlat
- (void)setMinimumSize:(CGSize)minimumSize; // default is CGSizeZero, can be used to avoid resizing for a larger message
- (void)setRingThickness:(CGFloat)width; // default is 2 pt
- (void)setRingRadius:(CGFloat)radius; // default is 18 pt
- (void)setRingNoTextRadius:(CGFloat)radius; // default is 24 pt
- (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt
- (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
- (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom
- (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom
- (void)setBackgroundLayerColor:(UIColor*)color; // default is [UIColor colorWithWhite:0 alpha:0.4], only used for SVProgressHUDMaskTypeCustom
- (void)setInfoImage:(UIImage*)image; // default is the bundled info image provided by Freepik
- (void)setSuccessImage:(UIImage*)image; // default is bundled success image from Freepik
- (void)setErrorImage:(UIImage*)image; // default is bundled error image from Freepik
- (void)setViewForExtension:(UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set
- (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval; // default is 5.0 seconds
- (void)setFadeInAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
- (void)setFadeOutAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
SVProgressHUD默认提供两种样式SVProgressHUDStyleLight,
SVProgressHUDStyleDark,一个是白色主题,一个是黑色主题。如果想自定义一些颜色可以通过setForegroundColor
setBackgroundColor不要忘记设置默认样式
通知,SVProgressHUD会使用到四个通知
SVProgressHUDWillAppearNotification
SVProgressHUDDidAppearNotification
SVProgressHUDWillDisappearNotification
SVProgressHUDDidDisappearNotification
每一通知会传递一个userinfo字典传递HUD的提示信息,key为SVProgressHUDStatusUserInfoKey。当用户触摸提示的整个屏幕的时候会发出SVProgressHUDDidReceiveTouchEventNotification通知,当用户直接触摸HUD的时候会发出SVProgressHUDDidTouchDownInsideNotification通知。