新聞中心
iOS中怎么自定義步驟進(jìn)度條,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
我們注重客戶提出的每個(gè)要求,我們充分考慮每一個(gè)細(xì)節(jié),我們積極的做好成都網(wǎng)站建設(shè)、做網(wǎng)站服務(wù),我們努力開拓更好的視野,通過(guò)不懈的努力,創(chuàng)新互聯(lián)贏得了業(yè)內(nèi)的良好聲譽(yù),這一切,也不斷的激勵(lì)著我們更好的服務(wù)客戶。 主要業(yè)務(wù):網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)站設(shè)計(jì),微信小程序,網(wǎng)站開發(fā),技術(shù)開發(fā)實(shí)力,DIV+CSS,PHP及ASP,ASP.Net,SQL數(shù)據(jù)庫(kù)的技術(shù)開發(fā)工程師。
實(shí)現(xiàn)方法如下:
1.用進(jìn)度條做的首先要解決的是進(jìn)度條的高度問(wèn)題,可以通過(guò)仿射變換來(lái)擴(kuò)大高度。
progressView.transform = CGAffineTransformMakeScale(1.0f,2.0f);
2.用進(jìn)度條要設(shè)置進(jìn)度progress要與按鈕對(duì)應(yīng)
通過(guò)步驟的索引來(lái)改變進(jìn)度的值和按鈕的圖片。由于按鈕的左右有間隔所以要注意-1、0和最后一個(gè)的progress值。
3.擴(kuò)展
看有一些類似查公交、車站運(yùn)行的APP有的可以點(diǎn)擊站點(diǎn),所以就用按鈕來(lái)做,這樣可以擴(kuò)展。
4.代碼
//// StepProgressView.h// CustomProgress//// Created by City--Online on 15/12/12.// Copyright © 2015年 City--Online. All rights reserved.//#import
//// StepProgressView.m// CustomProgress//// Created by City--Online on 15/12/12.// Copyright © 2015年 City--Online. All rights reserved.//#import "StepProgressView.h"static const float imgBtnWidth=18;@interface StepProgressView ()@property (nonatomic,strong) UIProgressView *progressView;//用UIButton防止以后有點(diǎn)擊事件@property (nonatomic,strong) NSMutableArray *imgBtnArray;@end@implementation StepProgressView+(instancetype)progressViewFrame:(CGRect)frame withTitleArray:(NSArray *)titleArray{ StepProgressView *stepProgressView=[[StepProgressView alloc]initWithFrame:frame]; //進(jìn)度條 stepProgressView.progressView=[[UIProgressView alloc]initWithFrame:CGRectMake(0, 5, frame.size.width, 10)]; stepProgressView.progressView.progressViewStyle=UIProgressViewStyleBar; stepProgressView.progressView.transform = CGAffineTransformMakeScale(1.0f,2.0f); stepProgressView.progressView.progressTintColor=[UIColor redColor]; stepProgressView.progressView.trackTintColor=[UIColor blueColor]; stepProgressView.progressView.progress=0.5; [stepProgressView addSubview:stepProgressView.progressView]; stepProgressView.imgBtnArray=[[NSMutableArray alloc]init]; float _btnWidth=frame.size.width/(titleArray.count); for (int i=0; i
5.使用和效果
NSArray *arr=@[@"區(qū)寶時(shí)尚",@"區(qū)寶時(shí)尚",@"時(shí)尚",@"區(qū)寶時(shí)尚",@"時(shí)尚"]; StepProgressView *stepView=[StepProgressView progressViewFrame:CGRectMake(0, 100, self.view.bounds.size.width, 60) withTitleArray:arr]; stepView.stepIndex=2; [self.view addSubview:stepView];
補(bǔ)充:上面的代碼有一個(gè)bug,例如stepIndex=-1時(shí),_stepIndex=并不等-1,原來(lái)數(shù)組的count返回的是NSUInteger而stepIndex是NSInteger類型,所以需要強(qiáng)制轉(zhuǎn)換一下
stepIndex=stepIndex<-1?-1:stepIndex; _stepIndex = stepIndex >= (NSInteger)(_imgBtnArray.count-1) ? _imgBtnArray.count-1:stepIndex;
關(guān)于iOS中怎么自定義步驟進(jìn)度條問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
名稱欄目:iOS中怎么自定義步驟進(jìn)度條
文章源于:http://fisionsoft.com.cn/article/ihppjg.html