欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

iOS中怎么自定義步驟進度條-創(chuàng)新互聯(lián)

iOS中怎么自定義步驟進度條,針對這個問題,這篇文章詳細介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

成都創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)新疆,十年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108

實現(xiàn)方法如下:

1.用進度條做的首先要解決的是進度條的高度問題,可以通過仿射變換來擴大高度。

progressView.transform = CGAffineTransformMakeScale(1.0f,2.0f);

2.用進度條要設(shè)置進度progress要與按鈕對應(yīng)

通過步驟的索引來改變進度的值和按鈕的圖片。由于按鈕的左右有間隔所以要注意-1、0和最后一個的progress值。

3.擴展

看有一些類似查公交、車站運行的APP有的可以點擊站點,所以就用按鈕來做,這樣可以擴展。

4.代碼

//// StepProgressView.h// CustomProgress//// Created by City--Online on 15/12/12.// Copyright &copy; 2015年 City--Online. All rights reserved.//#import <UIKit/UIKit.h>@interface StepProgressView : UIView@property (nonatomic,assign) NSInteger stepIndex;+(instancetype)progressViewFrame:(CGRect)frame withTitleArray:(NSArray *)titleArray;@end

//// StepProgressView.m// CustomProgress//// Created by City--Online on 15/12/12.// Copyright &copy; 2015年 City--Online. All rights reserved.//#import "StepProgressView.h"static const float imgBtnWidth=18;@interface StepProgressView ()@property (nonatomic,strong) UIProgressView *progressView;//用UIButton防止以后有點擊事件@property (nonatomic,strong) NSMutableArray *imgBtnArray;@end@implementation StepProgressView+(instancetype)progressViewFrame:(CGRect)frame withTitleArray:(NSArray *)titleArray{ StepProgressView *stepProgressView=[[StepProgressView alloc]initWithFrame:frame]; //進度條 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<titleArray.count; i++) {  //圖片按鈕 UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom]; [btn setImage:[UIImage imageNamed:@"0.png"] forState:UIControlStateNormal]; [btn setImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateSelected]; btn.frame=CGRectMake(_btnWidth/2+_btnWidth*i-imgBtnWidth/2, 0, imgBtnWidth, imgBtnWidth); btn.selected=YES; [stepProgressView addSubview:btn]; [stepProgressView.imgBtnArray addObject:btn]; //文字 UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(btn.center.x-_btnWidth/2, frame.size.height-20, _btnWidth, 20)]; titleLabel.text=[titleArray objectAtIndex:i]; [titleLabel setTextColor:[UIColor blackColor]]; titleLabel.textAlignment=NSTextAlignmentCenter; titleLabel.font=[UIFont systemFontOfSize:18]; [stepProgressView addSubview:titleLabel]; } stepProgressView.stepIndex=-1; return stepProgressView;}-(void)setStepIndex:(NSInteger)stepIndex{// 默認為-1 小于-1為-1 大于總數(shù)為總數(shù) _stepIndex=stepIndex<-1?-1:stepIndex; _stepIndex=stepIndex >=_imgBtnArray.count-1?_imgBtnArray.count-1:stepIndex; float _btnWidth=self.bounds.size.width/(_imgBtnArray.count); for (int i=0; i<_imgBtnArray.count; i++) { UIButton *btn=[_imgBtnArray objectAtIndex:i]; if (i<=_stepIndex) {  btn.selected=YES; } else{  btn.selected=NO; } } if (_stepIndex==-1) { self.progressView.progress=0.0; } else if (_stepIndex==_imgBtnArray.count-1) { self.progressView.progress=1.0; } else { self.progressView.progress=(0.5+_stepIndex)*_btnWidth/self.frame.size.width; }}@end

5.使用和效果

NSArray *arr=@[@"區(qū)寶時尚",@"區(qū)寶時尚",@"時尚",@"區(qū)寶時尚",@"時尚"]; StepProgressView *stepView=[StepProgressView progressViewFrame:CGRectMake(0, 100, self.view.bounds.size.width, 60) withTitleArray:arr]; stepView.stepIndex=2; [self.view addSubview:stepView];

補充:上面的代碼有一個bug,例如stepIndex=-1時,_stepIndex=并不等-1,原來數(shù)組的count返回的是NSUInteger而stepIndex是NSInteger類型,所以需要強制轉(zhuǎn)換一下

stepIndex=stepIndex<-1?-1:stepIndex; _stepIndex = stepIndex >= (NSInteger)(_imgBtnArray.count-1) ? _imgBtnArray.count-1:stepIndex;

關(guān)于iOS中怎么自定義步驟進度條問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。

本文名稱:iOS中怎么自定義步驟進度條-創(chuàng)新互聯(lián)
鏈接分享:http://aaarwkj.com/article8/coccip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標簽優(yōu)化面包屑導航、微信小程序、網(wǎng)站策劃、ChatGPT、App開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站
国产一区999精品在线| 午夜视频在线观看日韩| 国产麻豆剧传媒国产av| 熟女高潮av一区二区| 日进去了啊内射视频| 欧美欧美欧美欧美一区| 婷婷六月亚洲激情综合| 黄色av链接在线观看| av一区二区三区网站| 色综合色综合色综合色综合| 国产男女爱猛视频在线| 久久久久国产综合精品| 亚洲成人av网址大全| 婷婷中文字幕在线视频| 新人妻一区二区在线视频| 国产欧美日本综合一区| 日韩三级视频一区二区| 亚洲综合一区二区三区四区在线| 国产精品一区2区3区| 亚洲乱码在线中文字幕| 久久久这里只有精品99| 日韩一区二区免费看视频| 一区二区三区毛片在线看| 欧美日韩午夜福利视频| 国产一区二区三区婷婷 | 国产亚洲超级97免费视频| 欧美日韩亚洲中文国产| 亚洲精品一区av在线观看| av天天堂网在线播放| 免费人成网站在线观看| 国产精品偷伦一区二区| 2018在线不卡爱视频| 亚洲婷婷久久一区二区| 久久久久久精品国产免费| 亚洲午夜av久久乱码| 日本一区二区三区电影播放| 日韩精品成人一区二区三区免费 | 国产H精品在线观看| 97青青草免费在线视频| 日韩精品人成在线播放| 日韩有码中文字幕一区|