SVProgressHUD

https://github.com/TransitApp/SVProgressHUD

SVProgressHUD is a clean and easy-to-use HUD meant to display the progress of an ongoing task.

SVProgressHUD 是一个清新易用的指示器,用来指示正在执行的任务。

Installation

From CocoaPods CocoaPods安装

I'm not a big fan of CocoaPods, so tend to not keep it updated. If you really want to use SVProgressHUD with CocoaPods, I suggest you use pod 'SVProgressHUD', :head to pull from the master branch directly. I'm usually careful about what I push there and is the version I use myself in all my projects.

Manually 手动安装

  • Drag the SVProgressHUD/SVProgressHUD folder into your project.
  • Add the QuartzCore framework to your project.

Usage 使用

(see sample Xcode project in /Demo)

SVProgressHUD is created as a singleton (i.e. it doesn't need to be explicitly allocated and instantiated; you directly call [SVProgressHUD method]).

SVProgressHUD 是单例模式(也就是说你只需要调用[SVProgressHUD method]即可)

Use SVProgressHUD wisely! Only use it if you absolutely need to perform a task before taking the user forward. Bad use case examples: pull to refresh, infinite scrolling, sending message.

请明智的使用SVProgressHUD!仅仅当你确保绝对要执行一项任务了。以下是不当的使用情形:下拉刷新,发送消息,无限滚动

Using SVProgressHUD in your app will usually look as simple as this (using Grand Central Dispatch):

请以以下的方式使用SVProgressHUD

[SVProgressHUD show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// time-consuming task
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
});
});

Showing the HUD 显示指示器

You can show the status of indeterminate tasks using one of the following:

你可以用以下的方式来指示你在做什么:

+ (void)show;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;
+ (void)showWithStatus:(NSString*)string;
+ (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType;

If you'd like the HUD to reflect the progress of a task, use one of these:

如果你想显示任务的进度情况,用下面的方法:

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

Dismissing the HUD 隐藏指示器

It can be dismissed right away using:

你可以用以下方法隐藏指示器:

+ (void)dismiss;

If you'd like to stack HUDs, you can balance out every show call using:

如果你想用栈的方式存储按照顺序来显示,你可以依次调用以下方法:

+ (void)popActivity;

The HUD will get dismissed once the popActivity calls will match the number of show calls.

这个指示器会依照顺序依次消失

Or show a confirmation glyph before before getting dismissed 1 second later using:

或者按照标志位延时1s钟消失:

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

Customization

SVProgressHUD can be customized via the following methods:

SVProgressHUD 可以用以下方式定制:

+ (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor]
+ (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor]
+ (void)setRingThickness:(CGFloat)width; // default is 4 pt
+ (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
+ (void)setSuccessImage:(UIImage*)image; // default is bundled success image from Glyphish
+ (void)setErrorImage:(UIImage*)image; // default is bundled error image from Glyphish

Notifications

SVProgressHUD posts four notifications via NSNotificationCenter in response to being shown/dismissed:

SVProgressHUD 通过通知中心发送4种通知来显示/隐藏:

  • SVProgressHUDWillAppearNotification when the show animation starts
  • SVProgressHUDDidAppearNotification when the show animation completes
  • SVProgressHUDWillDisappearNotification when the dismiss animation starts
  • SVProgressHUDDidDisappearNotification when the dismiss animation completes

Each notification passes a userInfo dictionary holding the HUD's status string (if any), retrievable viaSVProgressHUDStatusUserInfoKey.

每一个通知都传递一个userInfo字典来装载HUD状态值,其值可以通过viaSVProgressHUDStatusUserInfoKey来获取。

SVProgressHUD also posts SVProgressHUDDidReceiveTouchEventNotification when users touch on the screen. For this notification userInfo is not passed but the object parameter contains the UIEvent that related to the touch.

SVProgressHUD当用户触摸屏幕的时候,也能发送SVProgressHUDDidReceiveTouchEventNotification。这种通知方式呢,并没有把userInfo当做参数来传递,取而代之的是object对象,包含了这个触摸的事件。

[翻译] SVProgressHUD的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. List的定制排序 包括使用lambda表达式来实现的方法

    1.先实现Comparator的接口 重写compare方法 根据比较大小来返回数值: 比如:(Integer o1  -   Integer o2); return 1 表示o1>o2; re ...

  2. rspec中的let和let!区别

    文档 https://relishapp.com/rspec/rspec-core/v/2-5/docs/helper-methods/let-and-let 从上面文档中得出 let 1 只会在一个 ...

  3. 多线程编程(四)-CyclicBarrier的使用

    CyclicBarrier的介绍 类CyclicBarrier不仅有CountDownLatch所具有的功能,还可以是啊县屏障等待的功能,也就是阶段性同步,它在使用上的意义在与可以循环地实现线程要一起 ...

  4. leetcode5:subsets问题

    问题描述: Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subse ...

  5. free 和 delete 把指针怎么了

    使用free或delete之后,只是把指针所指的内容给释放掉,但是指针并没有被干掉,还是指向原来位置(并不是执行NULL),此时指针指向的内容为垃圾,被称为“野指针”. 举例说明几个重要容易迷糊的特征 ...

  6. linux定时任务之crontab

    1.使用crontab crontab -u //设定某个用户的cron服务 crontab -l //列出某个用户cron服务的详细内容 crontab -r //删除某个用户的cron服务 cro ...

  7. 如何处理服务器SSL收到了一个弱临时Diffie-Hellman 密钥?

    当我们用火狐浏览器打开某个HTTPS网站时可能会失败,并且出现如下错误提示:         安全连接失败连接某个URL网址时发生错误. 在服务器密钥交换握手信息中 SSL 收到了一个弱临时 Diff ...

  8. java并发编程(10)Fork/Join

    Fork/Join JAVA7中出现的Fork/Join,类似于分布式文件系统hadoop的mapreduce思想,就是将任务分割,再分割,直到分割到满足条件 为了便于理解:编程逻辑可以借用 递归的思 ...

  9. select2插件改造之设置自定义选项 源码

    改造特性: 适应业务需要,选项里面包含“其他”其它”,可以点击填写并设置自定义选项 效果图: 具体代码不做阐述,如有类似需求,请私信.主要源码: /* Copyright 2012 Igor Vayn ...

  10. DateReader读取数据

    DateReader对象提供了用循序的.只读的方式读取Command对象获取的数据结果集正是因为DateReader是以循序的方法连续地读取数据,所以DateReader会以独占的方式打开数据库连接. ...