[翻译] MCProgressView 使用自定义图片做进度显示
MCProgressView 使用自定义图片做进度显示
https://github.com/Baglan/MCProgressView
Progress bar view with custom images.
使用自定义图片来显示进度条。
Installation(安装)
- Add the QuartzCore framework to your project;添加QuartzCore框架
- Copy files from the 'Classes' folder into your project.将‘Classes’文件夹拷贝到你的工程当中
Usage(使用)
You will first need to create custom images for background and foreground or copy the ones coming with this project to your project.
你需要创建两张图片,一张背景图一张最前面显示的图,或者直接从我的工程中拷贝出来。
#import "MCProgressBarView.h"
Initialize the images:
初始化图片:
UIImage * backgroundImage = [[UIImage imageNamed:@"progress-bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
UIImage * foregroundImage = [[UIImage imageNamed:@"progress-fg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
Notice the [UIImage -resizableImageWithCapInsets:] call. You can read more about it in the documnetation for this method. Essentiually, it defines which parts of the image will not be stretched when image is resized. Here, it's used to mark the left and the right edges.
注意这个方法[UIImage -resizableImageWithCapInsets:]的调用。你可以读读关于它的文档。实际上,它定义了图片中的哪些部分不会被拉伸。在这里我用来确保最左侧和最右侧不会被拉伸。
Create the view and add it to the view hierarchy:
直接创建这个view并添加进来:
MCProgressBarView * _progressBarView = [[MCProgressBarView alloc] initWithFrame:CGRectMake(25, 100, 270, 20)
backgroundImage:backgroundImage
foregroundImage:foregroundImage];
[self.view addSubview:_progressBarView];
Now, the progress you set (in the range of 0.0 to 1.0), will be reflected in the component:
现在,就会按照你设置的方式来显示进度了:
_progressBarView.progress = 0.25;
offsetForZero(0处的偏移量)
Matt Curtis pointed out that when progress is 0.0, there is still some initial progress indicator shown (see the image above). After some consideration, I've decided that there are situations when that is desirable and some situations when no progress should be shown. To address this, a new property has been added:
Matt Curtis 指出,当进度为0.0时,还是有一些进度显示出来了(看上面的图片)。之后我决定,某些特定的情况下不显示进度条而有时候显示,为了标志这个,我添加了一个新的属性:
@property (nonatomic, assign) CGFloat offsetForZero;
The default value of this property is the sum of the left and the right cap inset for the foreground image. To "taper off" the initial size of the progress indicator, you can set it to a lower value. For the images in the sample project, that value can be set to 10.0:
progressBarView.offsetForZero = 10.0;
See the sample image above to see the effect. That value can vary depending on the images you use in your project.
这个值会严重依赖于你所使用的图片。
[翻译] MCProgressView 使用自定义图片做进度显示的更多相关文章
- android 自定义图片圆形进度条
感觉话一个圆形进度条挺简单的 ,但是却偏偏给了几张图片让你话,说实话我没接触过,感觉好难,还好百度有大把的资源,一番努力下终于画出来了. 代码如下. package com.etong.cpms.wi ...
- easyui源码翻译1.32--Combo(自定义下拉框)
前言 扩展自$.fn.validatebox.defaults.使用$.fn.combo.defaults重写默认值对象.下载该插件翻译源码 自定义下拉框显示一个可编辑的文本框和下拉面板在html页面 ...
- html5 图片上传,支持图片预览、压缩、及进度显示,兼容IE6+及标准浏览器
以前写过上传组件,见 打造 html5 文件上传组件,实现进度显示及拖拽上传,兼容IE6+及其它标准浏览器,对付一般的上传没有问题,不过如果是上传图片,且需要预览的话,就力有不逮了,趁着闲暇时间,给上 ...
- [翻译] SFRoundProgressCounterView 带有进度显示的倒计时视图
SFRoundProgressCounterView 带有进度显示的倒计时视图 https://github.com/simpliflow/SFRoundProgressCounterView A c ...
- iOS View自定义窍门——UIButton实现上显示图片,下显示文字
“UIButton实现上显示图片,下显示文字”这个需求相信大家在开发中都或多或少会遇见.比如自定义分享View的时候.当然,也可以封装一个item,上边imageView,下边一个label.但是既然 ...
- 解决“用PicGo-2.3.0-beta5 + GitHub做博客图床,github仓库图片文件不显示”的问题记录(备忘)
解决"用PicGo-2.3.0-beta5 + GitHub做博客图床,github仓库图片文件不显示"的问题记录(备忘) 历时几个小时百度,终于靠自己理解解决了GitHub仓库图 ...
- [Android] 对自定义图片浏览器经常内存溢出的一些优化
首先关于异步加载图片可以参见 夏安明 的博客:http://blog.csdn.net/xiaanming/article/details/9825113 这篇文章最近有了新的更改,大概看了一下,内容 ...
- 灵活、可高度自定义的——Progress进度圈、弹窗、加载进度、小菊花
DDProgressHUD的介绍 提供了四种类型的展示: 显示无限旋转的加载图(比如小菊花,可以自定义),显示文字信息.网络刷新时经常用到. 显示加载进度的动画,也可以显示文字.网络下载时用的比较多, ...
- Android零基础入门第52节:自定义酷炫进度条
原文:Android零基础入门第52节:自定义酷炫进度条 Android系统默认的ProgressBar往往都不能满足实际开发需要,一般都会开发者自定义ProgressBar. 在Android开发中 ...
随机推荐
- Elastic-Job开发指南
开发指南 代码开发 作业类型 目前提供3种作业类型,分别是Simple,DataFlow和Script. DataFlow类型用于处理数据流,它又提供2种作业类型,分别是ThroughputDataF ...
- php 根据ip获取城市以及网络运营商名称(利用qqwry.dat)
根据用户IP地址判定出所在城市以及网络运营商 qqwry.dat下载地址:http://files.cnblogs.com/guangxiaoluo/qqwry.rar 解压出来即可 //获取用户真 ...
- 【LOJ】 #2025. 「JLOI / SHOI2016」方
题解 有什么LNOI啊,最后都是JLOI罢了 一道非常--懵逼的统计题 当然是容斥,所有的方案 - 至少有一个点坏掉的正方形 + 至少有两个点坏掉的正方形 - 至少有三个点坏掉的正方形 + 至少有四个 ...
- C#实现盛大盛付通充值卡状态查询
今天有这样一需求,要求能够查询盛付通卡的状态,官网如下 http://www.801335.com/status/index.htm 刚一打开网址,发现两个输入框加一个验证码,心中一喜不是小 cas ...
- IntelliJ IDEA 2017.2安装
1.准备(终极版) 2.安装 3.破解 4.成功
- js中对同步和异步的理解
你应该知道,javascript语言是一门“单线程”的语言,不像java语言,类继承Thread再来个thread.start就可以开辟一个线程,所以,javascript就像一条流水线,仅仅是一条流 ...
- [ 原创 ] Java基础8--什么叫做重载
重载是在同一个类中,有多个方法名相同,参数列表不同(参数个数不同,参数类型不同),与方法的返回值无关,与权限修饰符无关,B中的参数列表和题目的方法完全一样了.
- 机器学习之路: python 实践 word2vec 词向量技术
git: https://github.com/linyi0604/MachineLearning 词向量技术 Word2Vec 每个连续词汇片段都会对后面有一定制约 称为上下文context 找到句 ...
- BZOJ.4552.[HEOI2016/TJOI2016]排序(线段树合并/二分 线段树)
题目链接 对于序列上每一段连续区间的数我们都可以动态开点建一棵值域线段树.初始时就是\(n\)棵. 对于每次操作,我们可以将\([l,r]\)的数分别从之前它所属的若干段区间中分离出来,合并. 对于升 ...
- ZJOI2018 day2游记
省选讲课:还不错吧 ZJOI RP++ Day2: 题出的好!覆盖知识点广,题目又着切合实际的背景,解法比较自然. 给出题人点赞 ! 意识模糊地点开了题(考前不熬夜似乎还是很困qaq) T1:前一个小 ...