循环定时器

This commit is contained in:
kai60
2022-05-16 10:41:03 +08:00
parent 146e89a310
commit 0ab0c4fa08
20 changed files with 2390 additions and 231 deletions
+7 -5
View File
@@ -23,10 +23,12 @@
@property(nonatomic,copy)UIButton *sureButton;
@property(nonatomic)NSInteger row;
@property(nonatomic)NSInteger compennent;
@property(nonatomic,copy)NSString *startString;
@property(nonatomic,copy)NSString *endString;
@property(nonatomic,copy)NSString *startString1;
@property(nonatomic,copy)NSString *endString1;
@property(nonatomic,copy)NSString *startString;//开始时
@property(nonatomic,copy)NSString *endString;//开始分
@property(nonatomic,copy)NSString *startString1;//结束时
@property(nonatomic,copy)NSString *endString1;//结束分
@property(nonatomic,copy)NSString *startSecondString;//秒
@property(nonatomic,copy)NSString *endSecondString;
@property(nonatomic,copy)NSString *resultString;
@property(nonatomic,strong)UIImageView *backgroundImage;
@@ -36,8 +38,8 @@
@property(nonatomic,strong)UILabel *endLabel;
@property(nonatomic,assign)BOOL isNewXuanduo;
@property(nonatomic,assign)BOOL haveDelected;
@property(nonatomic,strong)NSString* pickerType;
+52 -17
View File
@@ -42,7 +42,7 @@
_endLabel.font=[UIFont systemFontOfSize:15];
_endLabel.textAlignment=NSTextAlignmentCenter;
[_backgroundImage addSubview:_endLabel];
_startString = _startString1 =_startSecondString= _endString = _endString1 = _endSecondString= @"00";
_picView=[[UIPickerView alloc]initWithFrame:CGRectMake(10,_startLabel.frame.origin.y + 20,imgWid - 20,imHeight -30 - 40- 20)];
_picView.dataSource=self;
@@ -104,8 +104,8 @@
return self;
}
- (void)setIsNewXuanduo:(BOOL)isNewXuanduo {
_isNewXuanduo = isNewXuanduo;
- (void)setPickerType:(NSString *)pickerType {
_pickerType = pickerType;
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(12,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)];
label1.text=@"小时";
label1.font=[UIFont systemFontOfSize:15];
@@ -151,12 +151,19 @@
}
-(void)initData{
if (_isNewXuanduo) {
if ([self.pickerType isEqualToString:@"xuanduo"]) {
_startString = _startString1 = _endString = _endString1 = @"00";
_dataArr = @[@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14"
,@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59"]];
}else {
}else if ([self.pickerType isEqualToString:@"cycleType"])
{
_startString = _startString1 = _endString = _endString1 = @"00";
_dataArr = @[@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14"
,@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59"],@[@"00",@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59"]];
}
else {
_dataArr=@[@[@"0:00",@"0:30",@"1:00",@"1:30",@"2:00",@"2:30",@"3:00",@"3:30",@"4:00",@"4:30",@"5:00",@"5:30",@"6:00",@"6:30",@"7:00",@"7:30",@"8:00",@"8:30",@"9:00",@"9:30",@"10:00",@"10:30",@"11:00",@"11:30",@"12:00",@"12:30",@"13:00",@"13:30",@"14:00",@"14:30",@"15:00",@"15:30",@"16:00",@"16:30",@"17:00",@"17:30",@"18:00",@"18:30",@"19:00",@"19:30",@"20:00",@"20:30",@"21:00",@"21:30",@"22:00",@"22:30",@"23:00",@"23:30"],@[@"0:29",@"0:59",@"1:29",@"1:59",@"2:29",@"2:59",@"3:29",@"3:59",@"4:29",@"4:59",@"5:29",@"5:59",@"6:29",@"6:59",@"7:29",@"7:59",@"8:29",@"8:59",@"9:29",@"9:59",@"10:29",@"10:59",@"11:29",@"11:59",@"12:29",@"12:59",@"13:29",@"13:59",@"14:29",@"14:59",@"15:29",@"15:59",@"16:29",@"16:59",@"17:29",@"17:59",@"18:29",@"18:59",@"19:29",@"19:59",@"20:29",@"20:59",@"21:29",@"21:59",@"22:29",@"22:59",@"23:29",@"23:59",]];
}
}
@@ -167,7 +174,7 @@
return rowArray.count;
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return _isNewXuanduo?4:2;
return _dataArr.count;
}
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
@@ -179,18 +186,46 @@
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
_row=row;
_compennent=component;
if (component==0) {
_startString=_dataArr[0][_row];
if ([self.pickerType isEqualToString:@"cycleType"])
{
if (component==0) {
_startString=_dataArr[0][_row];
}else if(component==1) {
_endString=_dataArr[1][_row];
}
else if (component==2){
_startSecondString=_dataArr[2][_row];
}else if (component==3){
_startString1=_dataArr[3][_row];
}
else if (component==4){
_endString1=_dataArr[4][_row];
}
else if (component==5){
_endSecondString=_dataArr[5][_row];
}
}else if(component==1) {
_endString=_dataArr[1][_row];
}else if (component==2){
_startString1=_dataArr[2][_row];
}else if (component==3){
_endString1=_dataArr[3][_row];
}
else
{
if (component==0) {
_startString=_dataArr[0][_row];
}else if(component==1) {
_endString=_dataArr[1][_row];
}else if (component==2){
_startString1=_dataArr[2][_row];
}else if (component==3){
_endString1=_dataArr[3][_row];
}
}
// [_picView selectRow:row inComponent:component animated:YES];
@@ -204,7 +239,7 @@
}
-(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{
return pickerView.frame.size.width/(_isNewXuanduo?4:2);
return pickerView.frame.size.width/_dataArr.count;
}