欢迎光临
我们一直在努力

iOS时间选择器

建站超值云服务器,限时71元/月

iOS时间选择器

项目介绍:

时间选择器https://github.com/xixihemaimai/pickerTime

  1. – (NSMutableArray *)recaptureTime:(NSString *)titleString{
  2.     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  3.     [formatter setDateFormat:@"HH"];
  4.     NSDateFormatter * formatter1 = [[NSDateFormatter alloc]init];
  5.     [formatter1 setDateFormat:@"mm"];
  6.     NSString * dateTime = [formatter stringFromDate:[NSDate date]];
  7.     NSString * minute = [formatter1 stringFromDate:[NSDate date]];
  8.     NSString * reloadYear = [self currentTime];
  9.     NSString * time = [NSString stringWithFormat:@"%@:%@",dateTime,minute];
  10.     NSMutableArray * timeArray = [NSMutableArray array];
  11.     NSArray * choiceTimeArray = @[@"00:00",@"00:30",@"01:00",@"01:30",@"02:00",@"02:30",@"03:00",@"03:30",@"04:00",@"04:30",@"05:00",@"05:30",@"06:00",@"06:30",@"07:00",@"07:30",@"08:00",@"08:30",@"09:00",@"09: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"];
  12.     NSString * rightNowStr = @"立刻送";
  13.     [timeArray removeAllObjects];
  14.     for (int i = 0; i < choiceTimeArray.count; i++) {
  15.         NSString * timeStr = choiceTimeArray;
  16.         BOOL resultYear = [titleString compare:reloadYear] == NSOrderedSame;
  17.         if (resultYear) {
  18.             BOOL result = [timeStr compare:time] == NSOrderedDescending;
  19.             if (result == 1){
  20.                 [timeArray addObject:choiceTimeArray];
  21.             }
  22.         }else{
  23.             [timeArray addObject:choiceTimeArray];
  24.         }
  25.     }
  26.     [timeArray insertObject:rightNowStr atIndex:0];
  27.     return timeArray;
  28. }

复制代码

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » iOS时间选择器
分享到: 更多 (0)