首页 > 玩机美化 > iOS实现步骤进度条功能实例代码

iOS实现步骤进度条功能实例代码

楼主:莫忘己 [1级] · 发表于2018-11-15 · 1401次浏览 · 玩机美化 ID:

在开发中,我们经常在很多场景下需要用到进度条,比如文件的下载,或者文件的上传等。 本文主要给大家介绍的是一个步骤进度条效果,步骤进度条效果参考

iOS UIKit 框架中并没有提供类似的控件,我们可以使用 UIProgressView、UIView、UILabel 组合实现步骤进度条效果。

UIProgressView——实现水平的进度条效果;

UIView——把UIView裁剪成圆形,实现索引节点效果;

UILabel——每个节点下面的提示文字。

源码

将步骤进度条封装成一个 HQLStepView 类,它是 UIView 的子类。

HQLStepView.h 文件䧦

#import

@interface HQLStepView : UIView

- 版权声明 - 1、本帖所有言论和图片等纯属网友个人意见,与流星社区立场无关;
2、其他单位或个人使用、转载或引用本帖时必须同时征得该帖子作者莫忘己流星社区的同意;
3、备注原文地址:https://bbs.liuxingw.com/t/7501.html,可忽略第2条;
4、帖子作者需承担一切因本文发表而直接或间接导致的相关责任;
5、如本帖内容或部分内容转载自其它媒体,这并不代表本站赞同其观点和对其真实性负责;
6、如本帖若为资源类,将仅限用于学习和研究目的,您必须在下载后的24个小时之内,从您安装或使用的设备中彻底删除上述内容;
7、如果您喜欢该程序,请支持正版软件,购买注册,可以得到更好的正版服务;
8、如本帖侵犯到任何版权或违法问题,请立即邮件告知我们,我们将及时予以处理。

打赏楼主,让Ta更有动力发帖~

4条回复 |  最后回复于2018-11-16

莫忘己 [1级]   回复于2018-11-15

源码将步骤进度条封装成一个 HQLStepView 类,它是 UIView 的子类。HQLStepView.h 文件?1234567891011#import @interface HQLStepView : UIView // 指定初始化方法- (instancetype)initWithFrame:(CGRect)frame titlesArray:(NSArray *)titlesArray stepIndex:(NSUInteger)stepIndex; // 设置当前步骤- (void)setStepIndex:(NSUInteger)stepIndex animation:(BOOL)animation; @end

回复列表

  • 内容加载中...

请输入回复内容

莫忘己 [1级]   回复于2018-11-15

HQLStepView.m 文件#import "HQLStepView.h" // 步骤条主题色#define TINT_COLOR [UIColor colorWithRed:35/255.f green:135/255.f blue:255/255.f alpha:1] @interface HQLStepView () @property (nonatomic, copy) NSArray *titlesArray;@property (nonatomic, assign) NSUInteger stepIndex; @property (nonatomic, strong) UIProgressView *progressView;@property (nonatomic, strong) NSMutableArray *circleViewArray;@property (nonatomic, strong) NSMutableArray *titleLabelArray;@property (nonatomic, strong) UILabel *indicatorLabel; @end @implementation HQLStepView #pragma mark - Init - (instancetype)initWithFrame:(CGRect)frame titlesArray:(NSArray *)titlesArray stepIndex:(NSUInteger)stepIndex { self = [super initWithFrame:frame]; if (self) { _titlesArray = [titlesArray copy]; _stepIndex = stepIndex; // 进度条 [self addSubview:self.progressView]; for (NSString *title in _titlesArray) { // 圆圈 UIView *circle = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 13, 13)]; circle.backgroundColor = [UIColor lightGrayColor]; circle.layer.cornerRadius = 13.0f / 2; [self addSubview:circle]; [self.circleViewArray addObject:circle]; // 标题 UILabel *label = [[UILabel alloc] init]; label.text = title; label.font = [UIFont systemFontOfSize:14]; label.textAlignment = NSTextAlignmentCenter; [self addSubview:label]; [self.titleLabelArray addObject:label]; } // 当前索引数字 [self addSubview:self.indicatorLabel]; } return self;} // 布局更新页面元素- (void)layoutSubviews { NSInteger pe

回复列表

  • 内容加载中...

请输入回复内容

渧钰 [1级]   回复于2018-11-16

你好,哥们,可以修改sol文件吗?一款单机游戏的存档,可以给星币

回复列表

  • 内容加载中...

请输入回复内容

啊浪一生一世 [1级]   回复于2018-11-16

我来了

回复列表

  • 内容加载中...

请输入回复内容
登录后才可进行评论
签到
57人签到
已签0天
  • 40726帖子
  • 1860775热点量
  • 528365火热值