Цветные строки TdCalendarView - PullRequest
0 голосов
/ 15 июня 2011

Я использую код TdCalendarView от Tinyfool в своем проекте, в котором весь календарь разработан с использованием основной графики. Я хочу покрасить строки этого календаря двумя альтернативными цветами. Как я могу это сделать?

1 Ответ

0 голосов
/ 15 июня 2011

Здесь необходимо изменить цвет заливки обводки либо для четного значения i in for loop, либо для нечетного значения

-(void)drawDateWords
  {
CGContextRef ctx=UIGraphicsGetCurrentContext();

int width=self.frame.size.width;

int dayCount=[self getDayCountOfaMonth:currentMonthDate];
int day=0;
int x=0;
int y=0;
int s_width=width/7;
int curr_Weekday=[self getMonthWeekday:currentMonthDate];

// Normaly big Font
[array_Date addObject:@""];
[array_Month addObject:@""];
[array_Year addObject:@""];
[array_Desc addObject:@""];
[array_LastDate addObject:@""];
[self.array_Name addObject:@""];


UIFont *weekfont=[UIFont boldSystemFontOfSize:20];

for(int i=1;i<dayCount+1;i++)
{
    day=i+curr_Weekday-2;
    x=day % 7;
    y=day / 7;
    NSString *date=[[[NSString alloc] initWithFormat:@"%d",i] autorelease];

    for (int j=0; j<[array_Date count]; j++) {

        NSString *date1 = [array_Date objectAtIndex:j];
        int month1 = [[array_Month objectAtIndex:j] intValue];
        int year1 = [[array_Year objectAtIndex:j] intValue];

    if ([date isEqualToString:date1] && currentMonthDate.month == month1 && currentMonthDate.year == year1)
    {
        //[@"*" drawAtPoint:CGPointMake(x*s_width+18,y*itemHeight+headHeight+18) withFont:[UIFont boldSystemFontOfSize:25]];
        //[date drawAtPoint:CGPointMake(x*s_width+18,y*itemHeight+headHeight+18) withFont:[UIFont boldSystemFontOfSize:25]];
        [[UIColor redColor] set];


    }
    else{
        //[[UIColor redColor] set];
        [date drawAtPoint:CGPointMake(x*s_width+15,y*itemHeight+headHeight) withFont:weekfont];
    }

    }

if([self getDayFlag:i]==1)
    {
        CGContextSetRGBFillColor(ctx, 1, 0, 0, 1);
        [@"." drawAtPoint:CGPointMake(x*s_width+19,y*itemHeight+headHeight+6) withFont:[UIFont boldSystemFontOfSize:25]];
    }
    else if([self getDayFlag:i]==-1)
    {
        CGContextSetRGBFillColor(ctx, 0, 8.5, 0.3, 1);
        [@"." drawAtPoint:CGPointMake(x*s_width+19,y*itemHeight+headHeight+6) withFont:[UIFont boldSystemFontOfSize:25]];
    }

    CGContextSetRGBFillColor(ctx, 0, 0, 0, 1);
}
 }
...