// 时间选择器
#import
typedefvoid(^GYTimeSelectPickerBlock) (NSString*timeString);
@interface GYTimeSelectPicker : UIView<UIPickerViewDelegate,UIPickerViewDataSource>
@property(nonatomic, strong)UIButton *deteBut;
@property(nonatomic, strong)UIButton *cancalBut;
@property(nonatomic, strong)GYTimeSelectPickerBlock timeBlock;
/* 初始化方法
frame :选择框的frame
arrData : 要展示的数据
*/
- (instancetype)initWithFrame:(CGRect)framestartTime:(NSString*)starTimeendTime:(NSString*)endTime;
@end
#import "GYTimeSelectPicker.h"
#define PickerHeight240
@interface GYTimeSelectPicker()
//时间可是为“2018-06-13 19:30”形式。
@property(nonatomic, strong)NSString *starTime;//开始时间
@property(nonatomic, strong)NSString *endTime;//结束时间
@property (nonatomic, strong)UIPickerView *pickerView;
@property (nonatomic, strong)NSMutableArray *yearArray;
@property (nonatomic, strong)NSMutableArray *monthArray;
@property (nonatomic, strong)NSMutableArray *monthMutableArray;
@property (nonatomic,strong)NSMutableArray *endMonthArr;
@property (nonatomic, strong)NSMutableArray *dayArray;
@property (nonatomic, strong)NSMutableArray *dayMutableArray;
@property (nonatomic, strong)NSMutableArray *endDayArr;
@property (nonatomic, strong)NSMutableArray *hourArray;
@property (nonatomic, strong)NSMutableArray *hourMutableArray;
@property (nonatomic, strong)NSMutableArray *endHourArr;
@property(nonatomic, strong)NSMutableArray *pointArray;
@property(nonatomic, strong)NSMutableArray *pointMutableArray;
@property(nonatomic, strong)NSMutableArray *endPointArr;
@end
@implementation GYTimeSelectPicker{
intyear;
intendYear;
intmonth;
intendMonth;
intday;
intendDay;
inthour;
intendHour;
intpoint;
intendPoint;
NSString*currentMonthString;
NSInteger m;
NSIntegerselectedYearRow;
}
- (instancetype)initWithFrame:(CGRect)framestartTime:(NSString*)starTimeendTime:(NSString*)endTime{
self= [superinitWithFrame:frame];
if(self)
{
[self setBackgroundColor:[UIColor whiteColor]];
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
self.starTime= starTime;
self.endTime= endTime;
[selfinitCtrl];
[selfaddTime];
}
return self;
}
-(void)initCtrl
{
self.backgroundColor = [UIColor clearColor];
UIButton *bgButton = [[UIButton alloc ] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
[bgButtonaddTarget:self action:@selector(onButtonCancel) forControlEvents:UIControlEventTouchUpInside];
bgButton.backgroundColor=RGBA(0,0,0,0.2);
[selfaddSubview:bgButton];
UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-PickerHeight, SCREEN_WIDTH, PickerHeight)];
bgView.backgroundColor = [UIColor whiteColor];
[selfaddSubview:bgView];
UIButton *btnCancel = [[UIButton alloc ] initWithFrame:CGRectMake(0, 0, 80, 40)];
[btnCancelsetTitle:@"取消" forState:UIControlStateNormal];
[btnCancelsetTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal];
[btnCanceladdTarget:self action:@selector(onButtonCancel) forControlEvents:UIControlEventTouchUpInside];
[bgViewaddSubview:btnCancel];
UILabel *selectLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 0, SCREEN_WIDTH-160, 40)];
selectLabel.text=@"请选择";
selectLabel.font = [UIFont systemFontOfSize:15];
selectLabel.textColor=UIColorFromRGB(0x333333);
selectLabel.textAlignment = NSTextAlignmentCenter;
[bgViewaddSubview:selectLabel];
UIButton *btnFinish = [[UIButton alloc ] initWithFrame:CGRectMake(self.frame.size.width-80, 0, 80, 40)];
[btnFinishsetTitle:@"完成" forState:UIControlStateNormal];
[btnFinishsetTitleColor:UIColorFromRGB(UI_COLOR_Exam_Red) forState:UIControlStateNormal];
[btnFinishaddTarget:self action:@selector(onButtonFinish) forControlEvents:UIControlEventTouchUpInside];
[bgViewaddSubview:btnFinish];
_pickerView = [[UIPickerView alloc ] initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH,PickerHeight-40)];
_pickerView.delegate = self;
_pickerView.dataSource = self;
[_pickerView setBackgroundColor:[UIColor colorWithRed:240.0/255 green:240.0/255 blue:240.0/255 alpha:1.0]];
[bgViewaddSubview:_pickerView];
}
- (void)viewTap:(UITapGestureRecognizer *)tap{
}
-(void) onButtonCancel
{
if(self)
{
[self removeFromSuperview];
}
}
-(void) onButtonFinish
{
NSString*time;
intcomponent0 = (int)[self.pickerViewselectedRowInComponent:0];
intcomponent1 = (int)[self.pickerViewselectedRowInComponent:1];
intcomponent2 = (int)[self.pickerViewselectedRowInComponent:2];
// int component3 = (int)[self.pickerView selectedRowInComponent:3];
// int component4 = (int)[self.pickerView selectedRowInComponent:4];
intselectedMon;
NSMutableArray*selectedMonArr;
if(component0 ==0&&component0 !=self.yearArray.count-1) {
selectedMon = [self.monthMutableArray[component1]intValue];
selectedMonArr = [self.monthMutableArraymutableCopy];
}elseif(component0 ==self.yearArray.count-1){
selectedMon = [self.endMonthArr[component1]intValue];
selectedMonArr = [self.endMonthArrmutableCopy];
}else{
selectedMon = [self.monthArray[component1]intValue];
selectedMonArr = [self.monthArraymutableCopy];
}
//年
time = [NSStringstringWithFormat:@"%@",self.yearArray[component0]];
//月
if(component0 ==0&& component0 !=self.yearArray.count-1) {
time = [NSStringstringWithFormat:@"%@-%@",time,self.monthMutableArray[component1]];
}elseif(component0 ==self.yearArray.count-1){
time = [NSStringstringWithFormat:@"%@-%@",time,self.endMonthArr[component1]];
}else
{
time = [NSStringstringWithFormat:@"%@-%@",time,self.monthArray[component1]];;
}
//日
if(component0==0&component1==0&&!(component0 ==self.yearArray.count-1&component1==selectedMonArr.count-1)) {
time = [NSStringstringWithFormat:@"%@-%@",time,self.dayMutableArray[component2]];
}elseif(component0 ==self.yearArray.count-1&component1==selectedMonArr.count-1){
time = [NSStringstringWithFormat:@"%@-%@",time,self.endDayArr[component2]];
}else{
time = [NSStringstringWithFormat:@"%@-%@",time,self.dayArray[component2]];
}
// //小时
// if (component0==0 &component1==0&&component2==0&&!(component0 == self.yearArray.count - 1 &&component1==self.endMonthArr.count-1 &&component2==self.endDayArr.count-1)) {
// time = [NSString stringWithFormat:@"%@ %@",time,self.hourMutableArray[component3]];
// }else if(component0 == self.yearArray.count - 1 &&component1==self.endMonthArr.count-1 &&component2==self.endDayArr.count-1){
// time = [NSString stringWithFormat:@"%@ %@",time,self.endHourArr[component3]];
// }else{
// time = [NSString stringWithFormat:@"%@ %@",time,self.hourArray[component3]];
// }
// //分
// if (component0==0 &component1==0&&component2==0&&component3==0&&!(component0 == self.yearArray.count - 1 &&component1==self.endMonthArr.count-1 &&component2==self.endDayArr.count-1 && component3 == self.endHourArr.count - 1)) {
// time = [NSString stringWithFormat:@"%@:%@",time,self.pointMutableArray[component4]];
// }else if(component0 == self.yearArray.count - 1 &&component1==self.endMonthArr.count-1 &&component2==self.endDayArr.count-1 && component3 == self.endHourArr.count - 1){
// time = [NSString stringWithFormat:@"%@:%@",time,self.endPointArr[component4]];
// }else{
// time = [NSString stringWithFormat:@"%@:%@",time,self.pointArray[component4]];
// }
if(self.timeBlock){
self.timeBlock(time);
}
//点击完成后,关闭当前view
[self onButtonCancel];
}
- (void)addTime{
//NSDate *date = [NSDate date];
NSDateFormatter *formatterS = [[NSDateFormatter alloc]init];
[formatterSsetDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate*starDate = [formatterSdateFromString:self.starTime];
NSDate*endDate = [formatterSdateFromString:self.endTime];
NSComparisonResultresult = [starDatecompare:endDate];
if(result ==NSOrderedDescending) {
NSLog(@"传入的时间 结束时间应 大于开始时间");
return;
}
// Get Current Year
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formattersetDateFormat:@"yyyy"];
NSString *currentyearString = [NSString stringWithFormat:@"%@",
[formatterstringFromDate:starDate]];
year=[currentyearStringintValue];
NSString *endyearString = [NSString stringWithFormat:@"%@",
[formatterstringFromDate:endDate]];
endYear= [endyearStringintValue];
// Get Current Month
[formattersetDateFormat:@"MM"];
currentMonthString = [NSString stringWithFormat:@"%ld",(long)[[formatter stringFromDate:starDate]integerValue]];
month=[currentMonthString intValue];
NSString *endMonthString =[NSString stringWithFormat:@"%ld",(long)[[formatter stringFromDate:endDate]integerValue]];
endMonth= [endMonthStringintValue];
// Get Current Date
[formattersetDateFormat:@"dd"];
NSString*currentDateString = [NSStringstringWithFormat:@"%@",[formatterstringFromDate:starDate]];
day=[currentDateStringintValue];
NSString*endDateString = [NSStringstringWithFormat:@"%@",[formatterstringFromDate:endDate]];
endDay=[endDateStringintValue];
[formattersetDateFormat:@"HH"];
NSString*currentHourString = [NSStringstringWithFormat:@"%@",[formatterstringFromDate:starDate]];
hour= [currentHourStringintValue];
NSString*endHourString = [NSStringstringWithFormat:@"%@",[formatterstringFromDate:endDate]];
endHour= [endHourStringintValue];
[formattersetDateFormat:@"mm"];
NSString*currentPointString = [NSStringstringWithFormat:@"%@",[formatterstringFromDate:starDate]];
point= [currentPointStringintValue];
NSString*endPointString = [NSStringstringWithFormat:@"%@",[formatterstringFromDate:endDate]];
endPoint= [endPointStringintValue];
self.yearArray = [NSMutableArray array];
self.monthArray = [NSMutableArray array];
self.monthMutableArray = [NSMutableArray array];
self.endMonthArr = [NSMutableArray array];
self.dayMutableArray = [NSMutableArray array];
self.dayArray = [NSMutableArray array];
self.endDayArr = [NSMutableArray array];
self.hourArray = [NSMutableArray array];
self.hourMutableArray = [NSMutableArray array];
self.endHourArr = [NSMutableArray array];
self.pointArray = [NSMutableArray array];
self.pointMutableArray = [NSMutableArray array];
self.endPointArr = [NSMutableArray array];
//年
for(inti =0; i <=endYear-year; i ++) {
NSString*yearString = [NSStringstringWithFormat:@"%d",year+ i];
[self.yearArrayaddObject:yearString];
}
//月份
if(endYear==year){
for(intt=month;t<=endMonth;t++){
NSString*endyearmonth = [NSStringstring];
if(t <10) {
endyearmonth = [NSStringstringWithFormat:@"0%d",t];
}else{
endyearmonth = [NSStringstringWithFormat:@"%d",t];
}
[self.endMonthArraddObject:endyearmonth];
}
}else{
for(intj=month; j <=12; j ++) {
NSString*yearmonth = [NSStringstring];
if(j <10) {
yearmonth = [NSStringstringWithFormat:@"0%d",j];
}else{
yearmonth = [NSStringstringWithFormat:@"%d",j];
}
[self.monthMutableArrayaddObject:yearmonth];
}
for(intt=1;t<=endMonth;t++){
NSString*endyearmonth = [NSStringstring];
if(t <10) {
endyearmonth = [NSStringstringWithFormat:@"0%d",t];
}else{
endyearmonth = [NSStringstringWithFormat:@"%d",t];
}
[self.endMonthArraddObject:endyearmonth];
}
for(intj=1; j <=12; j ++) {
NSString*yearmonth = [NSStringstring];
if(j <10) {
yearmonth = [NSStringstringWithFormat:@"0%d",j];
}else{
yearmonth = [NSStringstringWithFormat:@"%d",j];
}
[self.monthArrayaddObject:yearmonth];
}
}
//天
if(endYear == year && month == endMonth){
for(intt =day;t<=endDay;t++){
NSString*enddayString = [NSStringstring];
if(t <10) {
enddayString = [NSStringstringWithFormat:@"0%d",t];
}else{
enddayString = [NSStringstringWithFormat:@"%d",t];
}
[self.endDayArraddObject:enddayString];
}
}else{
for(inti =1; i <=31; i++)
{ NSString*dayString = [NSStringstring];
if(i <10) {
dayString = [NSStringstringWithFormat:@"0%d",i];
}else{
dayString = [NSStringstringWithFormat:@"%d",i];
}
[self.dayArrayaddObject:dayString];
}
for(inti =day; i <=31; i++)
{
NSString*dayString = [NSStringstring];
if(i <10) {
dayString = [NSStringstringWithFormat:@"0%d",i];
}else{
dayString = [NSStringstringWithFormat:@"%d",i];
}
[self.dayMutableArrayaddObject:dayString];
}
for(intt =1;t<=endDay;t++){
NSString*enddayString = [NSStringstring];
if(t <10) {
enddayString = [NSStringstringWithFormat:@"0%d",t];
}else{
enddayString = [NSStringstringWithFormat:@"%d",t];
}
[self.endDayArraddObject:enddayString];
}
}
//小时
if(endYear == year && month == endMonth && day == endDay){
for(intt =hour;t<=endHour;t++){
NSString*endhourString = [NSStringstring];
if(t <10) {
endhourString = [NSStringstringWithFormat:@"0%d",t];
}else{
endhourString = [NSStringstringWithFormat:@"%d",t];
}
[self.endHourArraddObject:endhourString];
}
}else{
for(inti =0; i <=23; i++)
{ NSString*hourString = [NSStringstring];
if(i <10) {
hourString = [NSStringstringWithFormat:@"0%d",i];
}else{
hourString = [NSStringstringWithFormat:@"%d",i];
}
[self.hourArrayaddObject:hourString];
}
for(inti =hour; i <=23; i++)
{
NSString*hourString = [NSStringstring];
if(i <10) {
hourString = [NSStringstringWithFormat:@"0%d",i];
}else{
hourString = [NSStringstringWithFormat:@"%d",i];
}
[self.hourMutableArrayaddObject:hourString];
}
for(intt =0;t<=endHour;t++){
NSString*endhourString = [NSStringstring];
if(t <10) {
endhourString = [NSStringstringWithFormat:@"0%d",t];
}else{
endhourString = [NSStringstringWithFormat:@"%d",t];
}
[self.endHourArraddObject:endhourString];
}
}
//分钟
if(endYear == year && month == endMonth && day == endDay){
for(inti =point; i <=endPoint; i++)
{
NSString*pointString = [NSStringstring];
if(i <10) {
pointString = [NSStringstringWithFormat:@"0%d",i];
}else{
pointString = [NSStringstringWithFormat:@"%d",i];
}
[self.endPointArraddObject:pointString];
}
}else{
for(inti =0; i <=59; i++)
{ NSString*pointString = [NSStringstring];
if(i <10) {
pointString = [NSStringstringWithFormat:@"0%d",i];
}else{
pointString = [NSStringstringWithFormat:@"%d",i];
}
[self.pointArrayaddObject:pointString];
}
for(inti =point; i <=59; i++)
{
NSString*pointString = [NSStringstring];
if(i <10) {
pointString = [NSStringstringWithFormat:@"0%d",i];
}else{
pointString = [NSStringstringWithFormat:@"%d",i];
}
[self.pointMutableArrayaddObject:pointString];
}
for(inti =0; i <=endPoint; i++)
{
NSString*pointString = [NSStringstring];
if(i <10) {
pointString = [NSStringstringWithFormat:@"0%d",i];
}else{
pointString = [NSStringstringWithFormat:@"%d",i];
}
[self.endPointArraddObject:pointString];
}
}
}
#pragma mark ------------ pickViewDelegate ------------
- (void)pickerView:(UIPickerView*)pickerViewdidSelectRow:(NSInteger)rowinComponent:(NSInteger)component
{
m=row;
if(component ==0)
{
selectedYearRow= row;
[self.pickerView reloadAllComponents];
}
elseif(component ==1)
{
//selectedMonthRow = row;
[self.pickerView reloadAllComponents];
}
elseif(component ==2)
{
//selectedDayRow = row;
[self.pickerView reloadAllComponents];
}elseif(component ==3){
//selectedHourRow = row;
[self.pickerView reloadAllComponents];
}
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return3;
}
// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView*)pickerViewnumberOfRowsInComponent:(NSInteger)component{
if(component ==0) {//年
returnself.yearArray.count;
}
if(component ==1) {//月
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
if(selectRow ==0&&selectRow !=self.yearArray.count-1) {
return[self.monthMutableArraycount];
}elseif(selectRow ==self.yearArray.count-1){
return[self.endMonthArrcount];
}else
{
return[self.monthArraycount];
}
}
if(component ==2) {//天
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
NSIntegerselectRow1 = [pickerViewselectedRowInComponent:1];
intselectedMon;
NSMutableArray*selectedMonArr;
if(selectRow ==0&& selectRow !=self.yearArray.count-1) {
selectedMon = [self.monthMutableArray[selectRow1]intValue];
selectedMonArr = [self.monthMutableArraymutableCopy];
}elseif(selectRow ==self.yearArray.count-1){
selectedMon = [self.endMonthArr[selectRow1]intValue];
selectedMonArr = [self.endMonthArrmutableCopy];
}else{
selectedMon = [self.monthArray[selectRow1]intValue];
selectedMonArr = [self.monthArraymutableCopy];
}
if(selectRow ==0&& selectRow !=self.yearArray.count-1&& selectRow1==0) {
//全选第一个row
if(selectedMon ==1|| selectedMon ==3|| selectedMon ==5|| selectedMon ==7|| selectedMon ==8|| selectedMon ==10|| selectedMon ==12)
{
returnself.dayMutableArray.count;
}elseif(selectedMon ==2)
{
intyearint = [[self.yearArrayobjectAtIndex:selectedYearRow]intValue];
if(((yearint %4==0)&&(yearint %100!=0))||(yearint %400==0)){
returnself.dayMutableArray.count-2;
}
else
{
returnself.dayMutableArray.count-3;// or return 29
}
}
else
{
returnself.dayMutableArray.count-1;
}
}elseif(selectRow ==self.yearArray.count-1&& selectRow1==selectedMonArr.count-1){
returnself.endDayArr.count;
}else{
//不是最后一个row 也 不是第一个row
if(selectedMon ==1|| selectedMon ==3|| selectedMon ==5|| selectedMon ==7|| selectedMon ==8|| selectedMon ==10|| selectedMon ==12)
{
return31;
}
elseif(selectedMon ==2)
{
intyearint = [[self.yearArrayobjectAtIndex:selectedYearRow]intValue];
if(((yearint %4==0)&&(yearint %100!=0))||(yearint %400==0)){
return29;
}
else
{
return28;// or return 29
}
}
else
{
return30;
}
}
}
if(component ==3) {//小时
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
NSIntegerselectRow1 = [pickerViewselectedRowInComponent:1];
NSIntegerselectRow2 = [pickerViewselectedRowInComponent:2];
if(selectRow ==0&&selectRow1==0 &&selectRow2==0&&!(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1&&selectRow2==self.endDayArr.count-1)) {
returnself.hourMutableArray.count;
}elseif(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1 &&selectRow2==self.endDayArr.count-1){
returnself.endHourArr.count;
}else{
returnself.hourArray.count;
}
}
if(component ==4) {//分钟
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
NSIntegerselectRow1 = [pickerViewselectedRowInComponent:1];
NSIntegerselectRow2 = [pickerViewselectedRowInComponent:2];
NSIntegerselectRow3 = [pickerViewselectedRowInComponent:3];
if(selectRow ==0&&selectRow1==0 &&selectRow2==0&& selectRow3 ==0&&!(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1 &&selectRow2==self.endDayArr.count-1&& selectRow3 ==self.endHourArr.count-1)) {
return self.pointMutableArray.count;
}elseif(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1 &&selectRow2==self.endDayArr.count-1&& selectRow3 ==self.endHourArr.count-1){
returnself.endPointArr.count;
}else{
returnself.pointArray.count;
}
}
return0;
}
- (UIView*)pickerView:(UIPickerView*)pickerViewviewForRow:(NSInteger)rowforComponent:(NSInteger)componentreusingView:(UIView*)view{
UILabel*pickerLabel = (UILabel*)view;
if(pickerLabel ==nil) {
CGRectframe =CGRectMake(0.0,0.0,60,50);
pickerLabel = [[UILabelalloc]initWithFrame:frame];
[pickerLabelsetTextAlignment:NSTextAlignmentCenter];
[pickerLabelsetBackgroundColor:[UIColor clearColor]];
[pickerLabelsetFont:[UIFont systemFontOfSize:16]];
}
if(component ==0)
{
pickerLabel.text= [NSStringstringWithFormat:@"%@%@",self.yearArray[row] ,@"年"];// Year
}
if(component ==1)
{
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
if(selectRow ==0&& selectRow !=self.yearArray.count-1) {
pickerLabel.text= [NSStringstringWithFormat:@"%@%@",self.monthMutableArray[row] ,@"月"];
}elseif(selectRow ==self.yearArray.count-1){
pickerLabel.text= [NSStringstringWithFormat:@"%@%@",self.endMonthArr[row] ,@"月"];
}else
{
pickerLabel.text= [NSStringstringWithFormat:@"%@%@",self.monthArray[row] ,@"月"];
}
}
if(component ==2)
{
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
NSIntegerselectRow1 = [pickerViewselectedRowInComponent:1];
intselectedMon;
NSMutableArray*selectedMonArr;
if(selectRow ==0&&selectRow !=self.yearArray.count-1) {
selectedMon = [self.monthMutableArray[selectRow1]intValue];
selectedMonArr = [self.monthMutableArraymutableCopy];
}elseif(selectRow ==self.yearArray.count-1){
selectedMon = [self.endMonthArr[selectRow1]intValue];
selectedMonArr = [self.endMonthArrmutableCopy];
}else{
selectedMon = [self.monthArray[selectRow1]intValue];
selectedMonArr = [self.monthArraymutableCopy];
}
if(selectRow==0&selectRow1==0&&!(selectRow ==self.yearArray.count-1&selectRow1==selectedMonArr.count-1)) {
pickerLabel.text= [NSStringstringWithFormat:@"%@%@",self.dayMutableArray[row] ,@"日"];
}elseif(selectRow ==self.yearArray.count-1&selectRow1==selectedMonArr.count-1){
//全选最后一个row
pickerLabel.text= [NSStringstringWithFormat:@"%@%@",self.endDayArr[row] ,@"日"];
}else{
pickerLabel.text= [NSStringstringWithFormat:@"%@%@",self.dayArray[row] ,@"日"];
}
}
if(component ==3) {
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
NSIntegerselectRow1 = [pickerViewselectedRowInComponent:1];
NSIntegerselectRow2 = [pickerViewselectedRowInComponent:2];
if(selectRow ==0&&selectRow1==0 &&selectRow2==0&&!(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1 &&selectRow2==self.endDayArr.count-1)) {
pickerLabel.text=[NSStringstringWithFormat:@"%@时",self.hourMutableArray[row]];
}elseif(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1 &&selectRow2==self.endDayArr.count-1){
pickerLabel.text=[NSStringstringWithFormat:@"%@时",self.endHourArr[row]];
}else{
pickerLabel.text=[NSStringstringWithFormat:@"%@时",self.hourArray[row]];
}
}
if(component ==4) {
NSIntegerselectRow = [pickerViewselectedRowInComponent:0];
NSIntegerselectRow1 = [pickerViewselectedRowInComponent:1];
NSIntegerselectRow2 = [pickerViewselectedRowInComponent:2];
NSIntegerselectRow3 = [pickerViewselectedRowInComponent:3];
if(selectRow ==0&&selectRow1==0 &&selectRow2==0&& selectRow3 ==0&&!(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1 &&selectRow2==self.endDayArr.count-1&& selectRow3 ==self.endHourArr.count-1)) {
pickerLabel.text=[NSStringstringWithFormat:@"%@分",self.pointMutableArray[row]];
}elseif(selectRow ==self.yearArray.count-1&&selectRow1==self.endMonthArr.count-1 &&selectRow2==self.endDayArr.count-1&& selectRow3 ==self.endHourArr.count-1){
pickerLabel.text= [NSStringstringWithFormat:@"%@分",self.endPointArr[row]];
}else{
pickerLabel.text= [NSStringstringWithFormat:@"%@分",self.pointArray[row]];
}
}
returnpickerLabel;
}
- (CGFloat)pickerView:(UIPickerView*)pickerViewrowHeightForComponent:(NSInteger)component{
return35;
}
@end