自定义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 ...
随机推荐
- linux 修改文件类型
:Unix及类Unix系统里,每行结尾只有换行“\n”,Windows系统里面,每行结尾是换行+回车“\n\r”. 利用Linux下的vim编辑器,可以方便的在dos文件.unix文件之间进行切换,且 ...
- Hibernate常见面试题(转)
在Java J2EE方面进行面试时,常被问起的Hibernate面试问题,大多都是针对基于Web的企业级应用开发者的角色的.Hibernate框架在Java界的成功和高度的可接受性使得它成为了Java ...
- Qt编写的开源帖子集合(懒人专用)
回顾自己学习Qt以来九年了,在这九年多时间里面,从本论坛学习不到不少的东西,今天特意整了一下自己开源过的资源的帖子,整理一起方便大家直接跳转下载,不统计不知道,一统计吓一跳,不知不觉开源了这么多代码, ...
- 自主移动机器人同时定位与地图创建(SLAM)方法概述
1.引言: 机器人的研究越来越多的得到关注和投入,随着计算机技术和人工智能的发展,智能自主移动机器人成为机器人领域的一个重要研究方向和研究热点.移动机器人的定位和地图创建是自主移动机器人领域的热点研究 ...
- G - SDOI
The Annual National Olympic of Information(NOI) will be held.The province of Shandong hold a Select( ...
- node.js 简单的获取命令参数
class Argvs { constructor() { this.argvsAll = this.argvsAll(); } argvsAll() { return process.argv.sl ...
- Page Visibility API 页面是否获取焦点 Event: visibilitychange
W3C 文档 https://www.w3.org/TR/page-visibility/ MDN 文档 https://www.w3.org/TR/page-visibility/ // Docum ...
- ELK之elasticdump迁移es数据
参考:https://www.cnblogs.com/resn/p/9082663.html elasticsearch部分查询语句 获取集群节点列表 curl "172.16.30.55: ...
- bootstrap modal 弹出其他页面
此文是可以的,是复制的然后粘贴 1.不使用js 方式 1.1 按钮 <a class=" btn default" href="ui_modals_ajax_sam ...
- This function has none of Deterministic,no sql,or reads sql data in its declaration and binary logging is enabled(you *might* want to use the less safe log_bin_trust_function_creators variable
This function has none of Deterministic,no sql,or reads sql data in its declaration and binary loggi ...