[翻译] SVProgressHUD
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/SVProgressHUDfolder 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种通知来显示/隐藏:
SVProgressHUDWillAppearNotificationwhen the show animation startsSVProgressHUDDidAppearNotificationwhen the show animation completesSVProgressHUDWillDisappearNotificationwhen the dismiss animation startsSVProgressHUDDidDisappearNotificationwhen 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的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- Java网络编程基础之TCP粘包拆包
TCP是个"流"协议,所谓流,就是没有界限的一串数据.大家可以想象河里的流水,他们是连成一片的,其间并没有分界线.TCP底层并不了解上层业务数据的具体含义,他会根据TCP缓冲区的实 ...
- python-锁机制
锁 Lock() Lock(指令锁)是可用的最低级的同步指令.Lock处于锁定状态时,不被特定的线程拥有.Lock包含两种状态——锁定和非锁定,以及两个基本的方法. 可以认为Lock有一个锁定池,当线 ...
- InnoDB索引概述,二分查找法,平衡二叉树
索引是应用程序设计和开发的一个重要方面.如果索引太多,应用的性能可能会受到影响:如果索引太少,对查询性能又会产生影响.要找到一个合适的平衡点,这对应用的性能至关重要. 如果知道数据的使用,从一开始就应 ...
- Hadoop Metrics2
来源:Hadoop Metrics2 Metrics are collections of information about Hadoop daemons, events and measureme ...
- [转]EntityFramework Core技术线路(EF7已经更名为EF Core,并于2016年6月底发布)
本文转自:http://www.cnblogs.com/VolcanoCloud/p/5572408.html 官方文档英文地址:https://github.com/aspnet/EntityFra ...
- 数据结构(三)--- B树(B-Tree)
文章图片代码来自邓俊辉老师的课件 概述 上图就是 B-Tree 的结构,可以看到这棵树和二叉树有点不同---"又矮又肥".同时子节点可以有若干个小的子节点构成.那么这样一棵树 ...
- ASP.NET 使用ajaxfileupload.js插件出现上传较大文件失败的解决方法(ajaxfileupload.js第一弹)
在写这篇的时候本来想把标题直接写成报错的提示,如下: “SecurityError:Blocked a frame with origin "http://localhost:55080&q ...
- [javaSE] 数据结构(二叉查找树-插入节点)
二叉查找树(Binary Search Tree),又被称为二叉搜索树,它是特殊的二叉树,左子树的节点值小于右子树的节点值. 定义二叉查找树 定义二叉树BSTree,它保护了二叉树的根节点BSTNod ...
- 多线程-定时器Timer
2019-04-1218:03:32 package 多线程.定时器Timer_重要; import java.util.Timer; import java.util.TimerTask; publ ...
- 二、socket编写简单BIO的HTTP服务器
一.目标 诸如tomcat等web服务器中间件简化了我们web的开发成本,但有时候我们或许并不需要这么一个完备的服务器,只是希望做一个简单地处理或者做特殊用途的服务器. 本文将提供一个HTTP的服务器 ...