自定义UIProgressView

自定义CustomporgressView
#import <UIKit/UIKit.h> @interface CustomporgressView : UIView
@property(nonatomic,assign)int step;
//allCount一共几个节点 step当前节点
-(instancetype)initWithFrame:(CGRect)frame withCount:(int)allCount withCurrentStep:(int)step;
@end
#import "CustomporgressView.h" #define TintColor [UIColor redColor]
#define TrackTintColor [UIColor lightGrayColor]
@interface CustomporgressView()
//进度条
@property(nonatomic,strong)UIProgressView *progressView;
//当前指示器
@property(nonatomic,strong)UILabel *indicatorLabel;
//圆点数组
@property(nonatomic,strong)NSMutableArray *mCircleArr; @end @implementation CustomporgressView -(instancetype)initWithFrame:(CGRect)frame withCount:(int)allCount withCurrentStep:(int)step{
self = [super initWithFrame:frame];
if(self){
self.progressView = [[UIProgressView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width*0.8, 0)];
self.progressView.center = self.center;
self.progressView.progressTintColor = TintColor;
self.progressView.trackTintColor = TrackTintColor;
[self addSubview:self.progressView]; self.mCircleArr = [NSMutableArray array];
float width = self.progressView.frame.size.width/(allCount-1);
for(int i=0;i<allCount;i++){
UIView *circleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 12, 12)];
circleView.center = CGPointMake(i * width,0);
circleView.clipsToBounds = YES;
circleView.layer.cornerRadius = 6.0f; [self.progressView addSubview:circleView];
[self.mCircleArr addObject:circleView];
}
[self.progressView addSubview:self.indicatorLabel];
self.step = step;
}
return self;
}
-(UILabel *)indicatorLabel{
if(!_indicatorLabel){
_indicatorLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
_indicatorLabel.textAlignment = NSTextAlignmentCenter;
_indicatorLabel.textColor = TintColor;
_indicatorLabel.layer.borderWidth = 1.0f;
_indicatorLabel.layer.cornerRadius = 12;
_indicatorLabel.layer.borderColor = TintColor.CGColor;
_indicatorLabel.backgroundColor = [UIColor whiteColor];
}
return _indicatorLabel;
} -(void)setStep:(int)step{
//超过数组边界
if(step >= self.mCircleArr.count){
return;
}
_step = step; for(int i=0;i<self.mCircleArr.count;i++){
UIView *circleView = self.mCircleArr[i];
if(i < step){
circleView.backgroundColor = TintColor;
}else{
circleView.backgroundColor = TrackTintColor;
}
} float width = self.progressView.frame.size.width/(self.mCircleArr.count-1);
self.indicatorLabel.center = CGPointMake(width * step, 0);
[ self.progressView setProgress:step*1.0/(self.mCircleArr.count-1)];
_indicatorLabel.text = [NSString stringWithFormat:@"%d",step+1]; } @end
使用:
CustomporgressView *customProgress = [[CustomporgressView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width-10, 50) withCount:5 withCurrentStep:2];
[view addSubview:customProgress];
自定义UIProgressView的更多相关文章
- Xamarin UIProgressView自定义
Progress.ProgressImage = UIImage.FromFile ("progress.png"); Progress.TrackImage = UIImage. ...
- UIProgressView 详解
自定义progressView 包括背景图片和进度条的图片以及进度条的高度. //进度条 UIProgressView *aProgressView = [[UIProgressView allo ...
- 关于Unity3D自定义编辑器的学习
被人物编辑器折腾了一个月,最终还是交了点成品上去(还要很多优化都还么做). 刚接手这项工作时觉得没概念,没想法,不知道.后来就去看<<Unity5.X从入门到精通>>中有关于 ...
- 一起学微软Power BI系列-使用技巧(5)自定义PowerBI时间日期表
1.日期函数表作用 经常使用Excel或者PowerBI,Power Pivot做报表,时间日期是一个重要的纬度,加上做一些钻取,时间日期函数表不可避免.所以今天就给大家分享一个自定义的做日期表的方法 ...
- JavaScript自定义浏览器滚动条兼容IE、 火狐和chrome
今天为大家分享一下我自己制作的浏览器滚动条,我们知道用css来自定义滚动条也是挺好的方式,css虽然能够改变chrome浏览器的滚动条样式可以自定义,css也能够改变IE浏览器滚动条的颜色.但是css ...
- ASP.NET Aries 入门开发教程8:树型列表及自定义右键菜单
前言: 前面几篇重点都在讲普通列表的相关操作. 本篇主要讲树型列表的操作. 框架在设计时,已经把树型列表和普通列表全面统一了操作,用法几乎是一致的. 下面介绍一些差距化的内容: 1:树型列表绑定: v ...
- ASP.NET Aries 入门开发教程5:自定义列表页工具栏区
前言: 抓紧时间,继续写教程,因为发现用户期待的内容,都在业务处理那一块. 不得不继续勤劳了. 这节主要介绍工具栏区的玩法. 工具栏的默认介绍: 工具栏默认包括5个按钮,根据不同的权限决定显示: 添加 ...
- UWP中实现自定义标题栏
UWP中实现自定义标题栏 0x00 起因 在UWP开发中,有时候我们希望实现自定义标题栏,例如在标题栏中加入搜索框.按钮之类的控件.搜了下资料居然在一个日文网站找到了一篇介绍这个主题的文章: http ...
- JavaScript 自定义对象
在Js中,除了Array.Date.Number等内置对象外,开发者可以通过Js代码创建自己的对象. 目录 1. 对象特性:描述对象的特性 2. 创建对象方式:对象直接量.new 构造函数.Objec ...
随机推荐
- bigtable原理
bigtable原理 数据模型 A Bigtable is a sparse, distributed, persistent multi-dimensional sorted map. The ma ...
- ORA-01841: (full) year must be between -4713 and +9999,
OGG报错日志: 2018-09-21 08:52:39 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, rep_1b.prm: Re ...
- 国内常用NTP服务器地址及
210.72.145.44 (国家授时中心服务器IP地址) 133.100.11.8 日本 福冈大学 time-a.nist.gov 129.6.15.28 NIST, Gaithersburg, M ...
- 7.11js的总结
<!DOCTYPE html> <html> <head> <title>js的内置全局函数</title> <script type ...
- E - TOYS
来源 poj 2318 Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad ...
- Spark RDD Action 简单用例(二)
foreach(f: T => Unit) 对RDD的所有元素应用f函数进行处理,f无返回值./** * Applies a function f to all elements of this ...
- ELK之使用kafka作为消息队列收集日志
参考:https://www.cnblogs.com/fengjian2016/p/5841556.html https://www.cnblogs.com/hei12138/p/7805475 ...
- 在eclipse中导入hadoop jar包,和必要时导入源码包。
1. 解药hadoop包 1, C:\hadoop-2.7.2\share\hadoop 提取出所有的 jar 包, 到 _lib 文件夹下 2,将有含有source 名称的jar包 剪切出来 3, ...
- Apache Sharding-Sphere
Sharding-Sphere 正式步入 Apache 基金会孵化器 - 开源中国 https://www.oschina.net/news/101691/sharding-sphere-enter- ...
- ionic中数据进行操作后,需要直接显示改变后的数据,数据刷新
数据分页是通过使用下拉加载,查询sqlite本地数据的数据 <ion-refresher (ionRefresh)="doTest($event)"> <ion- ...