惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
C
Check Point Blog
G
Google Developers Blog
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
D
Docker
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
Recent Announcements
Recent Announcements
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
阮一峰的网络日志
阮一峰的网络日志
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News

博客园 - 王彬iOS

AI时代iOS开发未来在哪里 iOS继承和多态 iOS OC中多线程总结 UIVIew和CALayer的区别 iOS远程推送APNs原理和基本配置 iOS App启动过程 写个文章 iOS强制关闭暗黑模式2021.12.2 【原创】关于github那些事:如何把项目提交到coding上/gitLab上 Mac-Macs Fan Control(控制温度、随时改变风扇转速、电脑降温) Excel使用基础 NSRunLoopCommonModes和NSDefaultRunLoopMode区别(Timer) 数据统计---埋点 【问题汇总】iOS数据持久化 iOS APP 如何做才安全 【问题汇总】 【原创】苹果设备数据标准 【面试题】iOS知识大全 Swift——convenience(便利构造函数)和类方法
SVProgressHUD方法
王彬iOS · 2018-06-11 · via 博客园 - 王彬iOS

第三方框架中关于HUD有MBProgressHUD和SVProgressHUD

我觉得会一种就可以了,综合前辈们的经验选择了后者,然后就花了一点时间,把他的方法都看了一下。在这里用作记录,供自己巩固和查阅。

方法

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

基本方法
 + (void)show;    显示:状态是一个迅速转动的圈
     + (void)showWithMaskType:(SVProgressHUDMaskType)maskType; 显示并且带着一个状态
     + (void)showWithStatus:(NSString*)status; 显示并且带着文字
     + (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;
     
     + (void)showProgress:(float)progress;  

关于HUD的属性配置

     + (void)setBackgroundColor:(UIColor*)color;       //背景颜色          // default is [UIColor whiteColor]
     + (void)setForegroundColor:(UIColor*)color;       

关于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];