美文网首页
SVProgressHUD的一些常见用法

SVProgressHUD的一些常见用法

作者: Aexsi | 来源:发表于2020-12-29 14:44 被阅读0次

方法

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为SVProgressHUDStatusUserInfoKey

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(@"执行完毕");
    }];
 
}

原文章:https://blog.csdn.net/wujakf/article/details/70882827

相关文章

  • SVProgressHUD的一些常见用法

    方法 SVProgressHUD所以的方法都是类方法,并且对象是通过单例创建。由于方法都是通过类名调用,简单明了。...

  • [iOS功能]- SVProgressHUD的一些常见用法

    SVProgressHUD GitHub地址:https://github.com/TransitApp/SVPr...

  • SVProgressHUD 简单用法

    SVProgressHUD 是一个第三方的控件,是一个弹出提示层,用来提示 网络加载 或 提示对错,看下面图,你就...

  • MBProgressHUD 源码解析

    HUD在iOS中一般特指“透明提示层”,常见的有SVProgressHUD、JGProgressHUD、Toast...

  • 英语常见错误

    小编为大家整理了一些英语中常见的错误,其中涉及介词用法、连词用法、副词用法、动词用法以及单词的选择,非常值得收藏!...

  • Asible常用模块

    主机连通测试 command模块 模块中常见的一些用法 用法实例: 3、shell 模块 shell模块可以在远程...

  • 一些常见命令的用法

    常用命令的使用方法 具体用法如下: ls的用法 通过ls命令不仅可以查看Linux文件夹包含的文件,而且可以查看文...

  • Handler 原理梳理

    简介# Handler 在 Android 开发中非常常见,它的常见用法相信只要稍微学过一些 Android 基础...

  • 一些常见的命令行

    一些常见的命令行 - 常见的自带命令 explainshell.com的用法 对于常见的命令行我们很容易能记住他们...

  • BMProgressHUD & SVProgressHU

    下载的地址:SVProgressHUD :https://github.com/SVProgressHUD/SVP...

网友评论

      本文标题:SVProgressHUD的一些常见用法

      本文链接:https://www.haomeiwen.com/subject/xywfoktx.html