如何在uitableview ios中根据开始时间上午10点和下午2点设置标签帧?

时间:2015-04-24 10:29:37

标签: ios iphone

请告诉我如何根据时间创建绘制uilabel框架,如下图所示

如何通过适当的块调整显示事件?

我可以找到重叠事件组,但无法设置块调整。例如: - 我有以下事件

1)从8:00到12:00事件A

2)从8:00到9:00事件B

3)从9:00到10:00事件C

4)从10:00到11:00事件D

5)从11:00到12:00事件E

应该如下图所示。

谢谢&问候 yogesh sharma

1 个答案:

答案 0 :(得分:0)

    -(void)currentTime
{    
    //Get current time
    NSDate* now = [NSDate date];
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *dateComponents = [gregorian components:(NSHourCalendarUnit  | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:now];
    NSInteger hour = [dateComponents hour];
    NSString *am_OR_pm=@"AM";

    if (hour>12)
    {
        hour=hour%12;

        am_OR_pm = @"PM";
    }

    NSInteger minute = [dateComponents minute];
    NSInteger second = [dateComponents second];
    [gregorian release];

    NSLog(@"Current Time  %@",[NSString stringWithFormat:@"%02d:%02d:%02d %@", hour, minute, second,am_OR_pm]);
}

此功能将为您提供当前时间。使用此功能,您可以构建标签

要创建和框架标签,您可以使用以下代码......

UILabel *fromLabel = [[UILabel alloc]initWithFrame:CGRectMake(91, 15, 10, 10)];