[翻译] KVNProgress
KVNProgress
KVNProgress is a fully customizable progress HUD that can be full screen or not.
KVNProgress是一个可以完全定制的HUD,你可以设置成全屏或者不全屏.
Advantages - 特点
- Can be full screen 可以全屏显示
- Uses
UIMotionEffect 使用了陀螺仪移动效果
- Supports all orientations 支持所有方向
- Supports iPad 支持iPad
- Animates text update 文本更新具有动画效果
- Animates success checkmark 成功时有动画效果
- Is well documented 文档完整
- Colors 颜色
- Fonts 字体
- Circle size and thickness 圆形形状以及厚度
Is fully customizable 可以高度定制
Requirements - 需要的环境
- Xcode 5
- iOS 7
- ARC
- Frameworks:
- QuartzCore
- GLKit
Installation - 安装
Cocoapods
CocoaPods recommended to use KVNProgress.
推荐使用CocoaPods来安装KVNProgress.
- Add
pod 'KVNProgress'
to your Podfile. - Install the pod(s) by running
pod install
. - Include KVNProgress wherever you need it with
#import <KVNProgress/KVNProgress.h>
.
Source files
- Download the latest code version or add the repository as a git submodule to your git-tracked project. 下载最新版本文件
- Drag and drop the Classes, Categories and also the Resources directory from the archive in your project navigator. Make sure to select Copy items when asked if you extracted the code archive outside of your project. 将文件Classes,Categories以及Resource拖到你的项目当中
- Include KVNProgress wherever you need it with
#import <KVNProgress/KVNProgress.h>
. 在需要使用的地方,引入头文件即可
Usage - 使用
Check out the provided demo app for many examples how you can use the components. 在demo中,你可以知道怎么使用这些组件
Basics
KVNProgress HUD will block the user from interacting with the interface behind it. You can customize colors, font and size of the HUD.
KVProgress HUD会屏蔽掉用户的交互,你可以定制颜色,字体以及HUD的尺寸
Add the following import to the top of the file or to your Prefix header:
将以下文件加到你的Prefix头文件中:
#import <KVNProgress/KVNProgress.h>
Indeterminate progress - 不确定进度的情形
To show an indeterminate progress:
显示一个不确定进度的HUD:
[KVNProgress show]; // Adds a status below the circle
[KVNProgress showWithStatus:@"Loading"]; // Adds the HUD to a certain view instead of main window
[KVNProgress showWithStatus:@"Loading"
onView:view];
To change the status on the fly (animated):
动态修改状态值:
[KVNProgress updateStatus:@"New status"];
Determinate progress - 确定进度的情形
To show a determinate progress and change its value along time:
显示一个有进度并随时改变值的情形:
// Progress has to be between 0 and 1
[KVNProgress showProgress:0.5f]; // Adds a status below the progress
[KVNProgress showProgress:0.5f
status:@"Loading"]; // Adds the HUD to a certain view instead of main window
[KVNProgress showProgress:0.5f
status:@"Loading"
onView:view]; // Updates the progress
[KVNProgress updateProgress:0.75f
animated:YES];
Dismiss - 隐藏
To dismiss after your task is done: 任务完成后,你可以隐藏它了:
// Dismiss
[KVNProgress dismiss];
When necessary, you can use: 如果有必要,你可以这么用:
// Dismiss
[KVNProgress dismissWithCompletion:^{
// Things you want to do after the HUD is gone.
}];
Why? 为什么?
Because KVNProgress remains visible for a certain time even if you call dismiss
. This is done to ensure the user has enough time to see the HUD if the load is too quick. The completion block indismissWithCompletion
is called (on the main thread) after the HUD is completely dismissed. This amount of time is defined in the KVNProgressConfiguration object (explained below). Default value is0.3
seconds.
因为KVNProgress会在dismiss的时候延时显示一小段时间.这是为了确保不会因为加载太快而看不到HUD.indismissWithCompletion会在HUD完全消失后执行.你可以设置这个延时消失的时间.
其默认值为0.3秒
Success/Error 成功/出错
To show a success HUD with a checkmark: 显示一个成功的HUD
[KVNProgress showSuccess]; // Or
[KVNProgress showSuccessWithStatus:@"Success"]; // Adds the HUD to a certain view instead of main window
[KVNProgress showSuccessWithStatus:@"Success"
onView:view];
To show an error HUD with a cross: 显示一个错误的HUD
[KVNProgress showError]; // Or
[KVNProgress showErrorWithStatus:@"Error"]; // Adds the HUD to a certain view instead of main window
[KVNProgress showErrorWithStatus:@"Error"
onView:view];
Dismiss is automatic for successes and errors. If you want to do something after the dismissal, you can use the above methods with the final
对于成功或者出错,HUD会自动消失,如果你想在消失之后做些事情,你可以用以上方法。
parameter completion
: showSuccessWithCompletion:
,showSuccessWithStatus:completion:
, showSuccessWithStatus:onView:completion:
,showErrorWithCompletion:
, showErrorWithStatus:completion:
,showErrorWithStatus:onView:completion:
.
Customization - 自定义
The appearance of KVNProgress is very customizable. If something is missing or could be added, don't hesitate to ask for it!
KVNProgress的可扩展性很好,有什么需要添加的,请毫不犹豫的给我提出来吧!
KVNProgressConfiguration
You can setup your HUD UI in your UI setups for your app using the KVNProgressConfiguration
. Here is an example on how to simply set the default configuration for you HUD:
[KVNProgress setConfiguration:[KVNProgressConfiguration defaultConfiguration]];
Note that if you just want the default configuration, the above code is not needed. If you do not set a configuration, the default one is taken ;)
Here is an example of a complete custom configuration:
KVNProgressConfiguration *configuration = [[KVNProgressConfiguration alloc] init]; configuration.statusColor = [UIColor whiteColor];
configuration.statusFont = [UIFont fontWithName:@"HelveticaNeue-Thin" size:15.0f];
configuration.circleStrokeForegroundColor = [UIColor whiteColor];
configuration.circleStrokeBackgroundColor = [UIColor colorWithWhite:1.0f alpha:0.3f];
configuration.circleFillBackgroundColor = [UIColor colorWithWhite:1.0f alpha:0.1f];
configuration.backgroundFillColor = [UIColor colorWithRed:0.173f green:0.263f blue:0.856f alpha:0.9f];
configuration.backgroundTintColor = [UIColor colorWithRed:0.173f green:0.263f blue:0.856f alpha:1.0f];
configuration.successColor = [UIColor whiteColor];
configuration.errorColor = [UIColor whiteColor];
configuration.circleSize = 110.0f;
configuration.lineWidth = 1.0f;
configuration.fullScreen = NO; [KVNProgress setConfiguration:configuration];
If you do not specify certain properties for a configuration, they will automatically be the default's one.
Display times
To avoid the user to see a blinking HUD or even don't see it at all if you are dismissing it too quickly, the HUD will stay display for a minimum (short) period of time.
There are 3 properties you can change that do that in KVNProgressConfiguration
to do that:
minimumDisplayTime
that has a default value of0.3
seconds. It handles all HUD's except for success and error ones.minimumSuccessDisplayTime
that has a default value of2.0
seconds. It handles all success HUD's.minimumErrorDisplayTime
that has a default value of1.3
seconds. It handles all error HUD's.
Remains to do
- Use real-time blur
[翻译] KVNProgress的更多相关文章
- 《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 ...
随机推荐
- 快速创建SpringBoot+SSM解析
此处使用IDEA快速搭建SpringBoot应用,首先用SpringBoot搭建WEB工程: 然后点击Next生成项目,首次生成可能有点慢,下次创建的时候就会快很多,生成后的目录结构如下: 我们更改下 ...
- Eclipse 安装spring插件spring tool suite(STS)
安装方法有2种,一种是在线安装,比较方便,但耗时较长,一种是离线安装,步骤复杂一些,但耗时少,下面请看详细步骤. 方法一:在线安装 1:打开eclipse菜单Help>Eclise Ma ...
- springMVC与Struts2区别
1.拦截级别 Struts2是类级别的拦截,一个类对应一个request上下文 SpringMVC是方法级别的拦截,一个方法对应一个request上下文,而方法同时又跟一个url对应 所以说从架构本身 ...
- java线程状态 以及 sheep()、wait()、yield() 区别
前言 最近看到很多人都在讨论多线程的问题,于是写出了这篇博客,希望可以帮到正在学习和使用这块的朋友们,首先我们先看看两个图(两个图都来自其他码农的分享) 这两个图是一样的逻辑,这里一起罗列出来,下 ...
- JavaScript设计模式-16.装饰者模式(上)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Dubbo源码解读
1.提升SOA的微服务架构设计能力 通过读dubbo源码是一条非常不错的通往SOA架构设计之路,毕竟SOA的服务治理就是dubbo首先提出来的,比起你去看市面上的SOA微服务架构的书籍,学到的架构 ...
- 有符号整数比较v.s.无符号整数比较
本文尝试从汇编的角度给出有符号整数比较与无符号整数比较的区别所在. 在<深入理解计算机系统>(英文版第二版)一书中的Page#77,有下面一个练习题: 将上述示例代码写入foo1.c文件, ...
- GB2312编码(为什么要加2020H、8080H,外码→内码→交换码→字形码)
为什么要加上2020H和8080H? 区位码.内码.国标码怎么转换非常简单,但是令人迷惑的是为什么要那么转换?这种转换不可能平白无故地那样转换! 我搜索很多资料,找到最好的解释,总结如下: 首先,注意 ...
- 有线mac 无线MAC 地址&&telnet要先开服务: ipconfig /all getma
在向IEEE申请到Mac address后,写到Lan设备里,就是Lan Mac,写到Wlan设备里,就是wlan Mac,写到BT设备里,就是BT Mac. MAC(Media Access Con ...
- 手把手教你使用 VuePress 搭建个人博客
手把手教你使用 VuePress 搭建个人博客 有阅读障碍的同学,可以跳过第一至四节,下载我写好的工具包: git clone https://github.com/zhangyunchencc/vu ...